Laravel 5 show ErrorException file_put_contents failed to open stream: No such file or directory

后端 未结 20 2121
北海茫月
北海茫月 2020-12-04 17:26

I have a project on Laravel 5 and I work with it at the office and at home too. It works fine, but recently at home it stopped working. Laravel show me two ErrorException

相关标签:
20条回答
  • 2020-12-04 18:00

    The best way to solve this problem is, go to directory laravel/bootstrap/cache and delete all files from cache.

    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

    In your panel or server, you can execute commands by adding the following to your routes:

        Route::get('/clear-cache', function() {
            $run = Artisan::call('config:clear');
            $run = Artisan::call('cache:clear');
            $run = Artisan::call('config:cache');
            return 'FINISHED';  
        });
    

    And then call the www.yourdomain.com/clear-cache route from your browser.

    0 讨论(0)
  • 2020-12-04 18:01

    If you are running laravel inside docker then access its filesystem

    $ docker exec -it name-of-laravel-container /bin/bash
    

    Next navigate to your laravel projects root directory. Make sure that you have inside storage/framework folder:

    1. cache
    2. sessions
    3. testing
    4. views

    And they should be both readable and writable.

    0 讨论(0)
  • 2020-12-04 18:02

    This type of issue generally occurs while migrating one server to another, one folder to another. Laravel keeps the cache and configuration (file name ) when the folder is different then this problem occurs.

    Solution Run Following command:

    php artisan config:cache
    

    https://laravel.com/docs/5.6/configuration#configuration-caching

    0 讨论(0)
  • 2020-12-04 18:06

    Clearing the contents of storage/framework/cache did the trick for me. Nothing else worked...

    0 讨论(0)
  • 2020-12-04 18:07

    I solved this problem via creating storage\framework\sessions folder.

    0 讨论(0)
  • 2020-12-04 18:09

    Apache + WSL on windows

    This is a silly mistake, and a different answer compared to the others, but I'll add it because it happened to me.

    If you use WSL (linux bash on windows) to manage your laravel application, while using your windows apache to run your server, then running any caching commands in the wsl will store the linux path rather than the windows path to the sessions and other folders.

    Solution

    Simply run the cache clearing commands in the powershell, rather than in WSL.

    $ php artisan optimize
    

    Was enough for me.

    0 讨论(0)
提交回复
热议问题