I\'m new to Laravel and I\'m trying to use the Artisan command...
php artisan serve
It displays...
Laravel developme
I had to restart my queue worker using php artisan queue:restart
after running php artisan key:generate
to get jobs working.
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.
I ran into this issue when I manually copied the contents of my Laravel project (say sites/oldname) into a new directory on my Mac (say, sites/newname). Since I was manually dragging and droppping, it didn't grab the hidden files, namely, '.env'. When I looked more closely at sites/oldname I saw .editorconfig, .env, .env.example, .gitatrributes, .styleci.yml, etc.
The error went away once I copied the hidden files to the new directory.
So, "No Application Encryption Key Has Been Specified" is Laravel speak for "your .env file is missing."
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.
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!
Open command prompt in the root folder of your project and run below command:
php artisan key:generate
It will generate Application Key for your application.
You can find the generated application key(APP_KEY) in .env
file.