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

后端 未结 20 2119
北海茫月
北海茫月 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 17:45

    I had similar problems because of .gitignore for the /storage folder on first machine, then cloned repository on second machine and laravel was revision to write down sessions cache

    So, manually creating folder /storage/sessions might be an solution..

    0 讨论(0)
  • 2020-12-04 17:48

    changing name of /bootstrap/cache/config.php to config.php.old doesn't work for me neither clearing cache with the commands artisan

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

    And for some weird reason I can't change permission for the owner on the directories, so my solution was running my IDE (Visual Studio Code) as admin, and everything works.

    My project is in an F:/ path of another disk.

    0 讨论(0)
  • 2020-12-04 17:49

    After some research I understand - I have very similar, but different root project locations and its cached in /bootstrap/cache. After cache clearing project started.

    0 讨论(0)
  • 2020-12-04 17:51

    In my case it was not anything that could be fixed with php artisan commands. The issue was folder permissions for the /storage folder. The error did not make that clear.

    0 讨论(0)
  • 2020-12-04 17:52

    Maybe there is an issue with your composer file. You could try:

    • composer install installs the vendor packages according to composer.lock (or creates composer.lock if not present),
    • composer update always regenerates composer.lock and installs the lastest versions of available packages based on composer.json

    • composer dump-autoload won’t download a thing. It just regenerates the list of all classes that need to be included in the project (autoload_classmap.php). Ideal for when you have a new class inside your project. Ideally, you execute composer dump-autoload -o , for a faster load of your webpages. The only reason it is not default, is because it takes a bit longer to generate (but is only slightly noticeable)

    source

    0 讨论(0)
  • 2020-12-04 17:53

    You should typically run the php artisan config:cache command as part of your production deployment routine. As a solution to your problem, I suggest you recreate the cache file, for faster configuration loading.

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

    • php artisan cache:clear
    • php artisan config:cache

    You can programmatically execute the command by adding the following to your routes:

    Route::get('/clear-cache', function() {
        $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.

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