Laravel 5 show ErrorException file_put_contents fa

2020-01-30 07:37发布

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

file_put_contents(G:\project\storage\framework\views/751d8a0fd8a7d4138c09ceb6a34bb377aa2d6265.php):
failed to open stream: No such file or directory

and

file_put_contents(G:\project\storage\framework/sessions/aIXycR4LIAUBVIqZu0T590paOMIpV8vfZGIroEp0):
failed to open stream: No such file or directory

I'm searching problem decision with Google and find information about correct rights. All advice is about Linux, but I'am work in Windows at the office and at home too.

When I try to clear application cache and view cache, artisan talk to me - ...cleared. But cache data and views are present in storage.

How can I fix this problem?

Thanks in advance!

14条回答
啃猪蹄的小仙女
2楼-- · 2020-01-30 07:48

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

查看更多
Anthone
3楼-- · 2020-01-30 07:52

Actually I faced this issue when I moved my project from server to local.

in

storage/framework

four basic folders are required cache, sessions, testing, views

In My case sessions was missing might be in gitignore.

So I manually created session folder and refreshed browser and it was working.

So any of the missing folder if we delete this problem can be solved.

查看更多
男人必须洒脱
4楼-- · 2020-01-30 07:54

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

查看更多
手持菜刀,她持情操
5楼-- · 2020-01-30 07:55

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.

查看更多
男人必须洒脱
6楼-- · 2020-01-30 07:55

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.

查看更多
劳资没心,怎么记你
7楼-- · 2020-01-30 07:58

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.

查看更多
登录 后发表回答