Home > Backend Development > PHP Tutorial > How to Clear Cache in Laravel 5 on Shared Hosting Without CLI Access?

How to Clear Cache in Laravel 5 on Shared Hosting Without CLI Access?

Susan Sarandon
Release: 2024-11-02 04:27:02
Original
428 people have browsed it

How to Clear Cache in Laravel 5 on Shared Hosting Without CLI Access?

Clearing Cache on Shared Hosting Without CLI Access in Laravel 5

Shared hosting servers often restrict access to the command-line interface (CLI), making it challenging to execute artisan commands like cache:clear. However, there are alternative ways to clear the cache in these situations.

One workaround is to call Artisan commands directly within your code. You can do this using the Artisan::call() method in your routes file:

<code class="php">Route::get('/clear-cache', function() {
    $exitCode = Artisan::call('optimize:clear');
    // return what you want
});</code>
Copy after login

This code will call the optimize:clear Artisan command, which will clear the cache. You can check the Laravel documentation for more information on callingArtisan commands outside the CLI: http://laravel.com/docs/5.0/artisan#calling-commands-outside-of-cli

It's important to note that the application cache is stored in the storage/framework/cache directory only if you configured the file driver in the config/cache.php file. You can choose different cache drivers, such as Redis or Memcached, to enhance performance compared to a file-based cache.

The above is the detailed content of How to Clear Cache in Laravel 5 on Shared Hosting Without CLI Access?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template