No Application Encryption Key Has Been Specified

2019-01-21 00:58发布

I'm new to Laravel and I'm trying to use the Artisan command...

php artisan serve

It displays...

Laravel development server started: http://127.0.0.1:8000

However, it won't automatically launch and when I manually enter http://127.0.0.1:8000 it shows this error:

RuntimeException No application encryption key has been specified.

Any ideas? I'm using Laravel framework 5.5-dev.

11条回答
霸刀☆藐视天下
2楼-- · 2019-01-21 01:02

Okay, I'll write another instruction, because didn't find the clear answer here. So if you faced such problems, follow this:

  1. Rename or copy/rename .env.example file in the root of your project to .env.

You should not just create empty .env file, but fill it with content of .env.example.

  1. In the terminal go to the project root directory(not public folder) and run

php artisan key:generate

  1. If everything is okay, the response in the terminal should look like this

Application key [base64:wbvPP9pBOwifnwu84BeKAVzmwM4TLvcVFowLcPAi6nA=] set successfully.

  1. Now just copy key itself and paste it in your .env file as the value to APP_KEY. Result line should look like this:

APP_KEY=base64:wbvPP9pBOwifnwu84BeKAVzmwM4TLvcVFowLcPAi6nA=

  1. In terminal run

php artisan config:cache

That's it.

查看更多
该账号已被封号
3楼-- · 2019-01-21 01:07

cp .env.example .env if there is no .env file present. php artisan key:generate command works for me. It generates the encryption key

查看更多
太酷不给撩
4楼-- · 2019-01-21 01:13

Run the command php artisan key:generate it will generate Application Key for your application. You can find the application key(APP_KEY) in .env file.

查看更多
女痞
5楼-- · 2019-01-21 01:15
  1. Copy .env.example to .env:

    cp -a .env.example .env

  2. Generate a key:

    php artisan key:generate

  3. Only then run:

    php artisan serve

查看更多
我想做一个坏孩纸
6楼-- · 2019-01-21 01:23
php artisan key:generate
php artisan config:cache

worked for me, but it had to be done in a command prompt on Windows.

Doing it inside the terminal in PHPStorm didn't worked.

查看更多
倾城 Initia
7楼-- · 2019-01-21 01:24

From Encryption - Laravel - The PHP Framework For Web Artisans:

"Before using Laravel's encrypter, you must set a key option in your config/app.php configuration file. You should use the php artisan key:generate command to generate this key"

I found that using this complex internet query in google.com:

"laravel add encrption key" (Yes, it worked even with the typo!)

查看更多
登录 后发表回答