Laravel 5.0 file_put_contents 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34725266/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 13:01:48  来源:igfitidea点击:

Laravel 5.0 file_put_contents error

phplaravellaravel-5

提问by Max

Just moved laravel project on hosting and it says:

刚刚在托管上移动了 laravel 项目,它说:

production.ERROR: exception 'ErrorException' with message 'file_put_contents(/Users/max/sites/evocate.dev/storage/framework/sessions/7f7df88c52734c34a3f89286dc74d517d446c4fd): failed to open stream: No such file or directory' in /home/f/fb7929gh/evocate2/vendor/compiled.php:6440

production.ERROR: 异常 'ErrorException' 带有消息 'file_put_contents(/Users/max/sites/evocate.dev/storage/framework/sessions/7f7df88c52734c34a3f89286dc74d517d446c4fd): 无法打开流: 没有这样的文件或目录/' fb7929gh/evocate2/vendor/compiled.php:6440

Why it takes my local host path and where can I fix this?

为什么它需要我的本地主机路径,我可以在哪里解决这个问题?

回答by Marcin Nabia?ek

You should make sure this directory exists and you have valid file permissions to this directory

您应该确保此目录存在并且您对该目录具有有效的文件权限

回答by Jijesh Cherrai

Make a directory sessionswith proper permission inside storage/frameworkYou can make directory using terminal command in Ubuntu:

sessions内部storage/framework创建一个具有适当权限的目录您可以在 Ubuntu 中使用终端命令创建目录:

sudo mkdir storage/framework/sessions

Or you can create a directory directly inside project-root-folder/storage/framework/sessions

或者你可以直接在里面创建一个目录 project-root-folder/storage/framework/sessions

And also check **storage**and **bootstrap**have the full permission to write. 777or 775

并且还检查**storage****bootstrap**拥有完全的写入权限。777或者775

回答by Elisha Senoo

This issue is due to the Laravel Configuration Caching. You should typically run the

这个问题是由于Laravel 配置缓存。您通常应该运行

php artisan config:cache

php工匠配置:缓存

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
  1. 删除配置缓存文件
  2. 刷新应用程序缓存
  3. 创建缓存文件以加快配置加载

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

为此,请在命令行上运行以下 Artisan 命令

  1. php artisan config:clear
  2. php artisan cache:clear
  3. php artisan config:cache
  1. php工匠配置:清除
  2. php artisan 缓存:清除
  3. php工匠配置:缓存

Where you don't have access to the command line on your server, you can programmatically execute commandslike this:

如果您无权访问服务器上的命令行,则可以通过编程方式执行如下命令

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

I hope this is helpful.

我希望这是有帮助的。