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.
This question is related to
php
laravel
laravel-5.1
From the line
'key' => env('APP_KEY', 'SomeRandomString'),
APP_KEY
is a global environment variable that is present inside the .env
file.
You can replace the application key if you trigger
php artisan key:generate
command. This will always generate the new key.
The output may be like this:
Application key [Idgz1PE3zO9iNc0E3oeH3CHDPX9MzZe3] set successfully.
Application key [base64:uynE8re8ybt2wabaBjqMwQvLczKlDSQJHCepqxmGffE=] set successfully.
Base64 encoding should be the default in Laravel 5.4
Note that when you first create your Laravel application, key:generate is automatically called.
Hash::make()
will no longer be valid.Just as another option if you want to print only the key (doesn't write the .env file) you can use:
php artisan key:generate --show
For me the problem was in that I had not yet ran composer update
for this new project/fork. The command failed silently, nothing happened.
After running composer update
it worked.
You can generate a key
by the following command:
php artisan key:generate
The key will be written automatically in your .env
file.
APP_KEY=YOUR_GENERATED_KEY
If you want to see your key
after generation use --show
option
php artisan key:generate --show
Note: The .env
is a hidden file in your project folder.
Source: Stackoverflow.com