laravel 错误:未指定应用程序加密密钥。但它存在
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/52985757/
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
Error: No application encryption key has been specified. But it exist
提问by Esmatullah Arifi
I have a Laravel application which is working well, but whenever I view the log file there are hundreds of error
我有一个运行良好的 Laravel 应用程序,但是每当我查看日志文件时,都会出现数百个错误
production.ERROR: No application encryption key has been specified. {"exception":"[object] (RuntimeException(code: 0): No application encryption key has been specified.
production.ERROR: 未指定应用程序加密密钥。{"exception":"[object] (RuntimeException(code: 0): 未指定应用程序加密密钥。
exist in log file. There is a key in .env
file and also I tried php artisan key:generate
command as well but the error still generated in log file without any visible error to users.
存在于日志文件中。中有一把钥匙。env
文件,我也尝试过php artisan key:generate
命令,但错误仍然在日志文件中生成,对用户没有任何可见的错误。
This error only appears in the production server's log file, not in my development pc.
此错误仅出现在生产服务器的日志文件中,而不出现在我的开发电脑中。
回答by Udhav Sarvaiya
php artisan key:generate
This will generate a random key, you must restart the serverand you should no longer see the error message.
这将生成一个随机密钥,您必须重新启动服务器,您应该不会再看到错误消息。
run the following commands to clear the cache.
运行以下命令清除缓存。
php artisan config:clear
php artisan config:cache
回答by Bilal Khan
I'm face to the same issue I have searched a lot but in a YouTube video comment I have found a solution (I'm not sure this solution is good or not) but worked for me
copy APP_KEY from .env file
and past in app.php file (located in: your_project\config)
Your app.php will look like
我面临着同样的问题,我已经搜索了很多,但在 YouTube 视频评论中我找到了一个解决方案(我不确定这个解决方案是否好)但对我
有用从 .env 文件复制 APP_KEY
并过去app.php 文件(位于:your_project\config)
你的 app.php 看起来像
.
.
.
‘key' => env(‘APP_KEY', ‘base64:insert key here'),
.
.
.
回答by Amol Rokade
check the "key" variable form your config/app.php file, it should be
检查 config/app.php 文件中的“key”变量,它应该是
'key' => env('APP_KEY'),
OR
或者
make like this
像这样
'key' => "Your key",
And Restart your php server.
并重新启动您的 php 服务器。
回答by Kapitan Teemo
try these commands:
试试这些命令:
composer install
php artisan key:generate
php artisan config:cache
回答by General Omosco
Add empty APP_KEY=
inside .env without value if not exist, then delete config.php
inside bootstrap/cache
run php artisan key:generate
APP_KEY=
如果不存在则config.php
在没有值的 .env 中添加空,然后在bootstrap/cache
运行中删除php artisan key:generate
回答by hardik prajapati
Yes the php artisan key:generate
will generate the key for you. like this in console
是的,php artisan key:generate
它将为您生成密钥。像这样在控制台
$php artisan key:generate
Application key [base64:soAqqNW/Kk85OclhmCKXj+u4nZGF142gEZHEY0Y1NXA=] set successfully.
$php artisan key:generate
Application key [base64:soAqqNW/Kk85OclhmCKXj+u4nZGF142gEZHEY0Y1NXA=] set successfully.
you need to copy this key and put it into your .env file in APP_KEY=
parameter.
您需要复制此密钥并将其放入您的 .env 文件中的APP_KEY=
参数中。