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:27

I actually had to add a .env file to my project and then copy the contents of .env.example so that the key:generate would work. Not sure why a .env file was not created when I started the project.

查看更多
何必那么认真
3楼-- · 2019-01-21 01:27

A common issue you might experience when working on a Laravel application is the exception:

RuntimeException No application encryption key has been specified.

You'll often run into this when you pull down an existing Laravel application, where you copy the .env.example file to .env but don't set a value for the APP_KEY variable.

At the command line, issue the following Artisan command to generate a key:

php artisan key:generate

This will generate a random key for APP_KEY, After completion of .env edit please enter this command in your terminal for clear cache:php artisan config:cache

Also, you have to restart the server now you will not get to see this error message.

查看更多
唯我独甜
4楼-- · 2019-01-21 01:28

In my case, I also needed to reset the cached config files:

php artisan key:generate
php artisan config:cache
查看更多
可以哭但决不认输i
5楼-- · 2019-01-21 01:28

You can generate Application Encryption Key using this command:

php artisan key:generate

Then, create a cache file for faster configuration loading using this command:

php artisan config:cache

Or, serve the application on the PHP development server using this command:

php artisan serve

That's it!

查看更多
等我变得足够好
6楼-- · 2019-01-21 01:29

simply run php artisan key:generate

查看更多
登录 后发表回答