osherdo's avatar

The cipher and / or key length are invalid. - why?

When trying access any of my views- I get this error message in return:

RuntimeException in EncryptionServiceProvider.php line 29: No supported encrypter found. The cipher and / or key length are invalid.

Couldn't find reasonable answer in Google.

what could it be ?

Thanks.

0 likes
16 replies
d3xt3r's avatar
d3xt3r
Best Answer
Level 29

Make sure you have .env file at root dir and then

php artisan key:generate
martinbean's avatar

@osherdo Set the value of APP_KEY to something that’s 32 characters long, and then run php artisan key:generate to generate a random, 32-character key.

osherdo's avatar

oddly I don't have .env file. what do I do?

d3xt3r's avatar

@osherdo For the second time, humbly asking you to take some time out to familiarise yourself with laravel framework https://laracasts.com/series/laravel-5-fundamentals. The questions you have are very very basic.

I am not saying we won't be helping but going through the tutorials once will definitely improve your learning/performance curve.

osherdo's avatar

@premsaurav before I am asking questions here - I am referring to the documentation and forums. only when I cannot find the answer/solution I am coming here to ask questions and get wiser. So I clearly say I couldn't find reliable source about how do I generate the .env file.

bashy's avatar

You say that but then I take 3 seconds to open up a new tab, go to laravel.com and check the install docs.

Application Key

The next thing you should do after installing Laravel is set your application key to a random string. If you installed Laravel via Composer or the Laravel installer, this key has already been set for you by the key:generate command. 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!

https://laravel.com/docs/5.2/installation

osherdo's avatar

too bad I forgot to tell you that even though I ran key:generate and no .env file has been generated.

There's no reference to how do I generate a new .env file in what you gave me. I also red that before you and it did not helped me really.

So basically right now there's NO env. file what so ever.

osherdo's avatar

so .ENV file is shown at the sublime text editor but not in the folder itself -noted it just now.

bashy's avatar

If you clone the repo from GitHub, you have to rename or copy the .env.example to .env

This explains it all for me;

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.

You should be using this if you're confused by the install instructions :P

composer create-project laravel/laravel folder-name
bashy's avatar

That's how you'd install a project, yes. But you'd see the commands it does which are listed in the composer.json file.

You should learn that before pulling repos from GitHub. Just my thoughts.

Please or to participate in this conversation.