I\'m new to Laravel and I\'m trying to use the Artisan command...
php artisan serve
It displays...
Laravel developme
cp .env.example .env
if there is no .env file present.
php artisan key:generate
command works for me. It generates the encryption key
Sometimes If everything Fails Use this:
Goto: laravelProject/config/app.php
Find the line: 'key' =>
and check to what it refers,
It can either be one of two:
Case 1: env('APP_KEY')
Case 2: "somekeystring"
For Case 1:
Goto your .env file after you have run cp -a .env.example .env
Enter a random string like 10101010101010101010101010101010
Now, run php artisan key:generate
Your key will be updated automatically.
For Case 2:
set a random string like for value of Key 10101010101010101010101010101010
Now, run php artisan key:generate
Your key will be updated automatically.
In my case, while cloning the project from git there was no .env
file. So I copy the .env
file from the source project and paste in my current project and change its configuration of database and it run successfully.
Copy .env.example
to .env
:
cp -a .env.example .env
Generate a key:
php artisan key:generate
Only then run:
php artisan serve
Follow this steps:
php artisan key:generate
php artisan config:cache
php artisan serve
If you git clone some project then this kind of issue may usually occur.
.env
filephp artisan key:generate
and then it should generate APP_KEY in .envphp artisan serve
and it should be working.