I am new to Laravel. I just started it tonight. Actually, I have the following code:
'key' => env('APP_KEY', 'SomeRandomString'),
In xampp/htdocs/laravel/blog/config/app.php.
I want to change this key to 32-bit by cmd as:
xampp\htdocs\laravel/blog>php artisan key:generate
It generates the key but could not replace/update in xampp/htdocs/laravel/blog/config/app.php.
Sometimes you might come across the "Laravel No Application Encryption Key Has Been Specified" error in Laravel and this commonly happens during a new Laravel project initialization. To solve this issue you will have to generate a APP_KEY which is located within your . env (environment) file.
php artisan key:generate is a command that sets the APP_KEY value in your . env file. By default, this command is run following a composer create-project laravel/laravel command.
The easiest way to generate the key is by using the artisans' command. After this, the APP_KEY value is automatically set in the . env file for you to use it later on. It is used to encrypt the files in your application.
This line in your app.php
, 'key' => env('APP_KEY', 'SomeRandomString'),
, is saying that the key for your application can be found in your .env
file on the line APP_KEY
.
Basically it tells Laravel to look for the key in the .env
file first and if there isn't one there then to use 'SomeRandomString'
.
When you use the php artisan key:generate
it will generate the new key to your .env
file and not the app.php
file.
As kotapeter said, your .env
will be inside your root Laravel directory and may be hidden; xampp/htdocs/laravel/blog
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With