【发布时间】:2019-01-30 14:39:00
【问题描述】:
如果 .env 在我的 Laravel 项目中被删除,则命令
$ php artisan key:generate
导致此错误
ErrorException : file_get_contents(/folder/projectlocation/.env): failed to open stream: No such file or directory at //folder/projectlocation/vendor/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php:96
{
file_put_contents(
$this->laravel->environmentFilePath(),
preg_replace(
$this->keyReplacementPattern(),
'APP_KEY='.$key,
file_get_contents($this->laravel->environmentFilePath())
));
}
但是php artisan serve 命令有效"Laravel development server started: <http://127.0.0.1:8000>"
我已经清除了所有的 Laravel 缓存。为什么它会服务但不获取 .env 文件配置?
【问题讨论】:
-
问题是什么? Env helper 接受默认值,这可能是它不抛出空项目异常的原因。
标签: laravel