Laravel 5.2:应用程序密钥的 Artisan 密钥生成无法正常工作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36291855/
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:29:44  来源:igfitidea点击:

Laravel 5.2: Artisan Key Generation for Application Key not working properly

phplaravelconfigurationkeyartisan

提问by Fabian

I try to Setup Laravel 5.2 on CentOS 7. When I try to generate the Application Key using the console command php artisan key:generatethe format of the Application Key is not as expected (longer than 32 characters including the base64 encode string and thus not working in the Configuration file.The cypher in config/app.php is AES-256-CBC.

我尝试在 CentOS 7 上安装 Laravel 5.2。当我尝试使用控制台命令生成应用程序密钥时,应用程序密钥php artisan key:generate的格式不符合预期(超过 32 个字符,包括 base64 编码字符串,因此在配置文件中不起作用.config/app.php 中的密码是 AES-256-CBC。

Example Output:

示例输出:

[base64:MTs0+UZ0tHljmRcFP1RpZ06aYpc1N1L3rqAx1FT+yqk=]

The server should have all required Extensions installed.

服务器应该安装了所有必需的扩展。

回答by Roj Vroemen

This is a change made recently to the key generator. See this commitfor more info.

这是最近对密钥生成器所做的更改。有关更多信息,请参阅此提交

Do you get an error stating that the key is invalid?

您是否收到一条错误消息,指出密钥无效?

回答by Ali Baig

put this in appServiceProvider.php

把它放在 appServiceProvider.php

use Illuminate\Support\Facades\Schema;
public function boot()
{
    Schema::defaultStringLength(191);
}

回答by Gopal Panadi

I dont know if you have resolved this issue.. This is how I solved the same.

我不知道你是否解决了这个问题。我就是这样解决的。

In the config/app.php, remove the env() and its parenthesis from the key.

在 config/app.php 中,从键中删除 env() 及其括号。

eg. 'key' => env('your_key')

例如。'key' => env('your_key')

should change it to..

应该改成..

'key' => 'your_key'

'key' => 'your_key'

I hope this helps you and others out there.

我希望这可以帮助你和其他人。