是否需要执行"php artisan key:generate"? laravel 5.7安装后的命令 [英] Is it necessary to execute "php artisan key:generate" command after installation of laravel 5.7
问题描述
我已经在系统中安装了 laravel 5.7 .我想知道是否有必要执行php artisan key:generate
命令?
I have installed laravel 5.7 in my system. I want to know that is it necessary to execute php artisan key:generate
command?
推荐答案
php artisan key:generate
php artisan key:generate
此命令在您的.env
文件中设置APP_KEY
值.
This command sets the APP_KEY
value in your .env
file.
如果您使用composer创建一个项目,则会使用project生成默认项目.
If you create a project with composer it'll generated default with project.
composer create-project laravel/laravel
如果使用git clone
克隆项目,则git会忽略某些文件夹,因此您可能无法获得env文件以及供应商文件夹.因此,他们必须手动输入php artisan key:generate
才能使他们的应用正常运行.
If you clone project using git clone
some folder is ignored by git so you might not get env file as well as vendor folder. Therefore, they will have to manually enter php artisan key:generate
for their app to function correctly.
因此,TL php artisan key:generate
时遵循的是预先创建的Laravel项目的clone
.
So, TL:DR the only time you need to call php artisan key:generate
is following a clone
of a pre-created Laravel project.
注意:如果您尝试在将APP_KEY
设置为SomeRandomString
的情况下运行Laravel项目(这是.env.example
文件中的默认设置,则实际上会出现错误:
Note: If you try to run a Laravel project with your APP_KEY
set to SomeRandomString
(which is the default in your .env.example
file, you will actually get an error:
未找到受支持的加密器.密码和/或密钥长度无效.
No supported encrypter found. The cipher and / or key length are invalid.
这篇关于是否需要执行"php artisan key:generate"? laravel 5.7安装后的命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!