Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 Application Key

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.

like image 390
Raham Avatar asked Nov 13 '15 19:11

Raham


People also ask

How do you fix no application encryption key has been specified Laravel?

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.

What is Artisan key generate?

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.

How can I get Laravel APP key?

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.


1 Answers

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

like image 161
James Avatar answered Sep 16 '22 16:09

James