laravel No supported encrypter found. The cipher and / or key length are invalid
Do you have all the necessary extensions installed on the server?
- PHP >= 5.5.9
- OpenSSL PHP Extension
- PDO PHP Extension
- Mbstring PHP Extension
- Tokenizer PHP Extension
It could be that you're missing the OpenSSL extension. Also, do you have the key set in .env
file?
Try running:
php artisan key:generate
Answer: the 'cipher' => ''
was not set.
No supported encrypter found. The cipher and / or key length are invalid with laravel
In the .env file set APP_KEY=
(without value) and save.
Then run the following commands:
php artisan key:generate
php artisan config:cache
It works for me.
No supported encrypter found. The cipher and / or key length are invalid in webhost
Login to your webserver using FTP (or equivalent) and find the .env
file. More than likely, this will be a copy of of the one you've used on localhost
.
The easiest way to fix this error is to find the line that starts with APP_KEY
and make sure it's 32 characters in length. If it's not, just add some random characters to make it 32 characters.
If you can't find the line starting with APP_KEY
, copy the line from your localhost .env
file and just user it on the webserver.
No supported encrypter found. The cipher and / or key length are invalid
The only time php artisan key:generate
needs to be manually called is when moving this project to a new environment, such as a development or production server. The reason you have to do this is this is shown the contents of the default .gitignore
file:
/vendor
/node_modules
.env
A copy of this project that is pushed to a new environment will not include .env
, which has the key APP_KEY=YourRandomKey
along with DB_PASSWORD
, MAIL_PASSWORD
, etc etc. Basically all the stuff you would keep private and allow new environment managers to configure by editing the .env.example
file that is pushed.
If you wanted to push these configuration variables with every copy of your project, you can, but I would highly recommend against this.
If you removed .env
from the .gitignore
file, the .env
file would be pushed to your repository and included in any git clone
ed projects.
Essentially, every copy of your project would have the same APP_KEY
variable, but it would also expose your DB_PASSWORD
, along with all other sensitive data found in .env
. Basically, there is a way to accomplish the level of security you get with Laravel, but in order to accomplish that, you're throwing that security out the window...
Hopefully that gives some insight.
Related Topics
Whats the Easiest Way to Determine If a User Is Online? (Php/Mysql)
What's the Most Efficient Test of Whether a PHP String Ends with Another String
Turn Off Deprecated Errors in PHP 5.3
Run a PHP Script Every Second Using Cli
Iterable Objects and Array Type Hinting
Loadhtml Libxml_Html_Noimplied on an HTML Fragment Generates Incorrect Tags
How to Display Xml in HTML in PHP
Highlight Keywords in a Paragraph
How to Downgrade or Install a Specific Version of Composer
How to Redirect Back to Form with Input - Laravel 5
Create New Xml File and Write Data to It
Getting Started with PHP Extension-Development