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.
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.A common issue you might experience when working on a Laravel application is the exception:
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 theAPP_KEY
variable.At the command line, issue the following Artisan command to generate a key:
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.
In my case, I also needed to reset the cached config files:
You can generate Application Encryption Key using this command:
Then, create a cache file for faster configuration loading using this command:
Or, serve the application on the PHP development server using this command:
That's it!
simply run
php artisan key:generate