I installed a new fresh copy of Laravel 5.3 using composer but I\'m getting this error:
The only supported ciphers are AES-128-CBC and AES-256-CBC wit
If you newly create a laravel project with command like composer create-project --prefer-dist laravel/laravel market
and deploy the new repo to the application path with cp command you may get this issue.
I use laravel 5.4
roofe@www:~/market$ php artisan --version
Laravel Framework 5.4.33
When you create the laravel project, you can see the the logs that create the key like this:
Generating autoload files
Illuminate\Foundation\ComposerScripts::postUpdate php artisan optimize Generating optimized class loader The compiled services file has been removed. php artisan key:generate Application key [base64:exxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/k=] set successfully.
By default the key config in the config/app.php is as follows, it use AES-256-CBC
and the generated key when creating the project is stored in the .env
file. If you use command like cp -r ./* /var/www/market/
the .env
file will not be moved to the application path.
/* |-------------------------------------------------------------------------- | Encryption Key |-------------------------------------------------------------------------- | | This key is used by the Illuminate encrypter service and should be set | to a random, 32 character string, otherwise these encrypted strings | will not be safe. Please do this before deploying an application! | */ 'key' => env('APP_KEY'), 'cipher' => 'AES-256-CBC',
When I chage my deploy command to cp -r ./* ./.env /var/www/market/
, this issue gone.
You also can refer to this github issue.
Check your .env file if APP_KEY is not set, it is the issue,
Now run php artisan key:generate
then run php artisan config:cache
it will set an APP_KEY key in your .env file.
If APP_KEY is already set run the same commands. It will update this key.
Just remove APP_KEY value from .env file and run this commands again :
php artisan key:generate
php artisan config:cache
Done.
Follow These Steps:
Step 1: Make sure you have .env file in your application.If not run this command cp .env.example .env
Step 2: Now run following command ( php artisan key:generate
) to generate a key and it will get saved in .env file automatically.
Step 3: Run php artisan config:cache
if you want to cache the configurtration Or php artisan config:clear
Hopefully it will fix everything.
For laravel version 5.4 PHP 7.4
php artisan key:generate
This will set a value for APP_KEY=
in your .env
file
something like this: APP_KEY=base64:trp5LQ9/TW85+17o0T7F0bZ/Ca1J9cIMgvyNIYl0k/g=
php artisan config:clear
then
php artisan config:cache
Hope this helps.
Run php artisan key:generate
.
Do php artisan config:clear
,
Then php artisan config:cache
And things will start working!