How to clear bootstrap cache in Laravel

Many times in application development, you may need to clear application. For example, for testing purposes, when we are making changes, to avoid the affect of previous implementation we clear cache. We can clear cache using the Controller or via CLI commands directly. In this tutorial we will learn how to clear bootstrap cache in Laravel. There are two ways to achieve this.

Clear bootstrap cache before you deploy the application

For bootstrap cache also, one method is to use an php artisan command in the command line. The cache:clear command can be passed via the CLI as an artisan command. This clears the entire application’s cache, including the bootstrap cache.

php artisan cache:clear

The command above flushes the entire application cache.

Clear cache manually

Bootstrap files can be manually cleared from the Laravel application without using the artisan command. The rm (remove) command can be passed inside the Laravel application folder alongside the bootstrap cache directory to flush all data present there. So you may navigate to your Laravel project folder and pass the command below.

rm -rf bootstrap/cache/*

The command above deletes the bootstrap/config.php file from the Laravel application. So, just manually delete bootstrap/config.php, also works to clear bootstrap cache in Laravel.

To clear the application bootstraper cache, php artisan optimize:clear may also help.

Leave a Comment