Home > Article > Backend Development > How to Clear Laravel 5 Cache on Shared Hosting Without CLI Access?
When working with Laravel 5 on shared hosting servers, it can be challenging to clear the cache effectively as you may not have direct access to Command Line Interface (CLI). This article provides a workaround to achieve this without using CLI, specifically focusing on clearing the views cache.
If your hosting provider restricts CLI access, you can still execute Artisan commands within your Laravel application by leveraging the following code:
<code class="php">Route::get('/clear-cache', function() { $exitCode = Artisan::call('optimize:clear'); // return desired output });</code>
This code defines a GET route that triggers the Artisan::call() method, which executes the 'optimize:clear' command. The exit code is stored in the $exitCode variable.
By default, Laravel 5 stores the application cache in the 'storage/framework/cache' directory. However, you can configure the file driver in the 'config/cache.php' file to utilize other cache storage options such as Redis or Memcached for enhanced performance.
The above is the detailed content of How to Clear Laravel 5 Cache on Shared Hosting Without CLI Access?. For more information, please follow other related articles on the PHP Chinese website!