Hi I'm new to this team development. If I add .env file everything works fine but if I remove it there is an error The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.. How to make it work? Thank you
Your .env file (or your environment) need to have an APP_KEY variable, which Laravel uses for encryption. You can generate a key with php artisan key:generate --show.
Related
In Laravel 6 Documentation second paragraph of Application Key written like this
Typically, this string should be 32 characters long. The key can be
set in the .env environment file. If you have not renamed the
.env.example file to .env, you should do that now. If the application
key is not set, your user sessions and other encrypted data will not
be secure!
Why did they ask to rename it? I also found this paragraph in the Laravel older version. Is there any difference between those since they have the same content but different name?
If you've install Laravel using composer command.
composer create-project laravel/laravel projectname
you don't need renamed the .env.example file to .env. If you installed Laravel via Composer or the Laravel installer, this key has already been set for you by the php artisan key:generate command.
If you clone project using git clone some folder is ignored by git so you might not get env file as well as vendor folder. Therefore, they will have to manually enter php artisan key:generate for their app to function correctly.
More info SO answer
Laravel need to use .env file to define a database connection, some general setting like application key as well. So if you have no .env file, your Laravel has not a setting for now.
Like they said, If the application key is not set, your user sessions and other encrypted data will not be secure! You need to create / copy /remove the .env.example to the new .env for this reason. for letting our Laravel knows about general config.
By the way, do not use the .env.example like copy-and-paste because it's an example. you need to change the value config to your own.
The simplest way is move it on your server with Filezilla or another FTP program. Rename file, and re-download it on your computer. It works for me last time :)
The .env.example the file is just an example of the .env file. It is not used by the app. It is used to serve as a base for you to edit and rename.
In a fresh Laravel installation, the root directory of your application will contain a .env.example file. If you install Laravel via Composer, this file will automatically be renamed to .env. Otherwise, you should rename the file manually.
i am trying to host a laravel 5.6 app on heroku and after pushing all the files on line and running the app i get the error
(1/1) RuntimeException
The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.
i have tried placing the AES-128-CBC on config/app.php file then uploading and then rining artisan key:generate then artisan config:cache but am still getting the same same error.
My database is hosted on db4free.net.
Run PHP artisan key:generate in your command. It automatically appends base64 to your constant values.
I hope this helps someone.
Adding base64:2egG+ to the string in the environment file worked for me
My problem is that i tried to upload my project to the server (using filezilla uploaded the whole thing) and encountered this error:
"The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths."
Searching on google, people says its a key problem on .env file. But that wasn't my case. the Key is there, I even use php artisan key:generate. it's like the server isn't reading the .env file
I tried config:cache and uploaded the "config.php" that was generated inside the cache folder and now the app cant finds the "views" because the paths are not the server paths but the local ones.
I tried everything, even uploading a fresh laravel installation and again: "The only supported ciphers are AES-128-CBC.."
Also tried config:cache on the server using the routes:
Route::get('/config-cache', function() { $exitCode = Artisan::call('config:cache'); return 'done.'; });
But i get this error: "putenv() has been disabled for security reasons"
I don't really know how to proceed..
You are getting this error because you have to generate key
try
php artisan key:generate
Or generate locally then replace it with .env
APP_KEY=YourGeneratedKey
I uploaded all laravel project on server, its working fine on local but getting error on server, even database configuration and key is configured in env. file. even i renamed .env.example file as .env too but got same error.
Error is
"Whoops, looks like something went wrong."
my error log is here:
[2017-11-06 15:19:07] local.ERROR: exception 'RuntimeException' with
message 'The only supported ciphers are AES-128-CBC and AES-256-CBC
with the correct key lengths.' in
/home/rndspot5/public_html/dev/lea/vendor/laravel/framework/src/Illuminate/Encryption/Encrypter.php:43
Judging from your error, you need to run php artisan key:generate this will update your key of which in turn will rectify your error.
You will need to either SSH into your public_html folder if you have host permission to do so. Alternatively, you can ask your host provider to either:
Grant you SSH access
Perform this action for you.
You can then run: php artisan config:clear once the new key has been generated.
If you are on shared hosting you can use these steps
Open your .env file, copy APP_KEY to somewhere else as a backup
Run php artisan key:generate from console
Copy the new APP_KEY and upload it to the .env file on your (shared) server
Move the old key back to development
I resolved this issue, by adding web app url in .env and Config/App.php and now its working :) thanks all of you for sharing such a value able knowledge that will help me, may be later.
Hello guys so I uploaded my app to Heroku. I want to mention that when I run php artisan:serve it all works fine without any problem but when I upload it to the heroku server I have a problem with the following error
The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.
Now I had the same error localy but I fixed it. now I can't seem to find how to fix it when I the app is uploaded. Any help would be appriciated. Thank you.
You need a key in your .env
php artisan key:generate
And make sure .env exists
As #EddyTheDove mentioned,
php artisan key:generate
This makes sure that the APP_KEY variable is set in the .env file. When you open the .env file, you should see the same key that was generated after you executed the command.
And make sure .env exists
This is located in your project folder.
ALSO:
Remember to use the ENTIRE key.
The "base64:" part of the generated key is also important, because it encodes the random string and provides an encryption key of the required length.