How to Solve ErrorException file_put_contents failed to open stream: No such file or directory in Laravel 5.7

The best way to solve this problem is,

You should typically run the php artisan config:cache command as part of your production deployment routine. I suggest you

  1. Remove the configuration cache file
  2. Flush the application cache
  3. Create a cache file for faster configuration loading

To do this, run the following Artisan commands on your command line

  1. php artisan config:clear
  2. php artisan cache:clear
  3. php artisan config:cache

Where you don’t have access to the command line on your server, you can programmatically execute commands by adding the following to your routes:

Route::get('/clear-cache', function() {
    $exitCode = Artisan::call('config:clear');
    $exitCode = Artisan::call('cache:clear');
    $exitCode = Artisan::call('config:cache');
    return 'DONE'; //Return anything
});

And then call the clear-cache route from your browser.

I hope this is helpful.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.