是否需要执行"php artisan key:generate"? laravel 5.7安装后的命令 [英] Is it necessary to execute "php artisan key:generate" command after installation of laravel 5.7

查看:240
本文介绍了是否需要执行"php artisan key:generate"? 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆