Is it necessary to execute “php artisan key:generate” command after installation of laravel 5.7

删除回忆录丶 提交于 2020-01-15 07:47:36

问题


I have installed laravel 5.7 in my system. I want to know that is it necessary to execute php artisan key:generate command?


回答1:


php artisan key:generate

This command sets the APP_KEY value in your .env file.

If you create a project with composer it'll generated default with project.

composer create-project laravel/laravel

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.

So, TL:DR the only time you need to call php artisan key:generate is following a clone of a pre-created Laravel project.

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.




回答2:


It is not always necessary to execute the php artisan key: generated command after the installation time.


  1. If you get this error then you must run this command: php artisan key: generated

    RuntimeException No application encryption key has been specified.

    • php artisan key:generate This will generate a random key for APP_KEY in .env file
  2. If you have not received this error then you do not need to worry about APP_KEY, because If you install Laravel via Composer, this key has already been set for you




回答3:


You don't need to run that command in a fresh install of laravel.




回答4:


Yes it is necessary to execute:

 php artisan key:generate 

Refer this link for futher information: Laravel 5 Application Key

I hope this will help you..



来源:https://stackoverflow.com/questions/58056181/is-it-necessary-to-execute-php-artisan-keygenerate-command-after-installation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!