Adding a command to laravel deleting all unwanted users :-)

As spammer start flooding my users table with fake-accounts i startet to develop a command for laravel to run in a cron job for deleting all users which didnt verified their email within the last 24 hours.

A nice how-to do a laravel console command for cron can be found at: https://tutsforweb.com/how-to-set-up-task-scheduling-cron-job-in-laravel/

This is my routine to select all users which haven’t confirmed their email and their register date is older than 24 hours.

Added the following command to the crontab by crontab -e on the webserver to execute the command:

Set Laravel-Project to “down” during updates

Everytime i start an update of the whole project it takes hours to upload all the new updated files to my web server.

To avoid a massive downtime for the user without informing them about the status and displaying any errors i just touch a file within the project:

project->storage->framework

there i add a file called “down” and the site goes into “down-mode” – atfer i finished my work i rename the file to “down-” to bring up the site agein. I configured the Error 503 page to display a nicer version of the error.

Error Class ‘Illuminate\Database\Grammar’ not found

Today i updated RolandRadio.net because i had some new packages i wanted to use. On my local Laravel instalation everything worked fine but after uploading the new changed files i got an error:

Error Class ‘Illuminate\Database\Grammar’ not found

I didn’t figured out how to fix this and suggested that it has soething to do with updates of laravel that occured during my development and so the local laravel version and the version on my webserver where different.

After uploading all the files again completely instead of only the different ones the website worked again. Maybe my FTP-Client has messed up some files. As the Upload of those files takes about 2,5 hours i should think about using GIT to avoid those long downtime and commit my changes more often to the GIT repository then.

How to disable the Cache in Laravel

Sometimes its necessary to disable the caching in Laravel. To do so a new cache-driver “none” must be added to the cache-configuration-file in config/cache.php

After that you have to set this cache-driver in your .env-File and you Cache is disabled

Edit .env and change the line
CACHE_DRIVER=file
to
CACHE_DRIVER=none

Clearing some Caches in Laravel

Clear Application Cache:

Clear Route Cache

Throws an error if CACHE_DRIVER=none

Clear Configuration Cache

Throws an error if CACHE_DRIVER=none

 Clear Compiled Views Cache

Throws an error if CACHE_DRIVER=none