The only supported ciphers are AES-128-CBC and AES-256-CBC #9080

Closed
mstnorris opened this Issue Jun 4, 2015 · 81 comments

Comments

Projects
None yet
@mstnorris

@GrahamCampbell

This comment has been minimized.

Show comment
Hide comment
@GrahamCampbell

GrahamCampbell Jun 4, 2015

Member

You need to follow our upgrading guide.

Member

GrahamCampbell commented Jun 4, 2015

You need to follow our upgrading guide.

@GrahamCampbell

This comment has been minimized.

Show comment
Hide comment
@GrahamCampbell

GrahamCampbell Jun 4, 2015

Member

and it looks like a Symfony component was removed that handles the decoding.

No?

Member

GrahamCampbell commented Jun 4, 2015

and it looks like a Symfony component was removed that handles the decoding.

No?

@mstnorris

This comment has been minimized.

Show comment
Hide comment
@mstnorris

mstnorris Jun 4, 2015

@GrahamCampbell Thanks but I don't have a 'cipher' key in my config/app.php. I've added it and it works, however I didn't remove it so the upgrade guide is misleading.

@GrahamCampbell Thanks but I don't have a 'cipher' key in my config/app.php. I've added it and it works, however I didn't remove it so the upgrade guide is misleading.

@andrewtweber

This comment has been minimized.

Show comment
Hide comment
@andrewtweber

andrewtweber Jul 14, 2015

In config/app.php I have

'cipher' => 'AES-128-CBC',

In my .env file I have APP_KEY of length 32 characters. I am getting the same error as above.
I also tried php artisan key:generate, which created a new key of length 16 characters, but it still has the same error message.

In config/app.php I have

'cipher' => 'AES-128-CBC',

In my .env file I have APP_KEY of length 32 characters. I am getting the same error as above.
I also tried php artisan key:generate, which created a new key of length 16 characters, but it still has the same error message.

@GrahamCampbell

This comment has been minimized.

Show comment
Hide comment
@GrahamCampbell

GrahamCampbell Jul 14, 2015

Member

You likely need to clear the config cache.

Member

GrahamCampbell commented Jul 14, 2015

You likely need to clear the config cache.

@andrewtweber

This comment has been minimized.

Show comment
Hide comment
@andrewtweber

andrewtweber Jul 14, 2015

Ok sorry.. I think artisan config:clear may have done the trick... it was looking for the wrong env variable in another location, so the key was an empty string. Rookie mistake. Thanks.

Ok sorry.. I think artisan config:clear may have done the trick... it was looking for the wrong env variable in another location, so the key was an empty string. Rookie mistake. Thanks.

@shakirblouch

This comment has been minimized.

Show comment
Hide comment
@shakirblouch

shakirblouch May 27, 2016

run this command

php artisan key:generate

and the clear config cache using

php artisan config:clear

will solve this problem

run this command

php artisan key:generate

and the clear config cache using

php artisan config:clear

will solve this problem

@GrahamCampbell

This comment has been minimized.

Show comment
Hide comment
@GrahamCampbell

GrahamCampbell May 27, 2016

Member

You should run confg:cache rather than clear.

Member

GrahamCampbell commented May 27, 2016

You should run confg:cache rather than clear.

@gp187

This comment has been minimized.

Show comment
Hide comment
@gp187

gp187 Aug 25, 2016

The problem I encountered is in config/app.php as a default after key:generate this was the result.
'key' => env('32charshere'),

The problem is the key is empty for config and doesn't get registered, that's why the error

change to
'key' => '32charshere',

and works

gp187 commented Aug 25, 2016

The problem I encountered is in config/app.php as a default after key:generate this was the result.
'key' => env('32charshere'),

The problem is the key is empty for config and doesn't get registered, that's why the error

change to
'key' => '32charshere',

and works

@zhekaus

This comment has been minimized.

Show comment
Hide comment
@zhekaus

zhekaus Aug 31, 2016

Try run 'php artisan key:generate' again if you have such an issue.

zhekaus commented Aug 31, 2016

Try run 'php artisan key:generate' again if you have such an issue.

@kimpastro

This comment has been minimized.

Show comment
Hide comment
@kimpastro

kimpastro Sep 6, 2016

In my case, the composer do not generate .env file. So i've created it, then execute key:generate and it works!

In my case, the composer do not generate .env file. So i've created it, then execute key:generate and it works!

@tinthenet

This comment has been minimized.

Show comment
Hide comment
@tinthenet

tinthenet Sep 21, 2016

In my case, I just run the command php artisan config:clear. Thank you!

In my case, I just run the command php artisan config:clear. Thank you!

@mdkieran

This comment has been minimized.

Show comment
Hide comment
@mdkieran

mdkieran Oct 9, 2016

I get this error if I refresh the page too quickly, otherwise it works fine.

mdkieran commented Oct 9, 2016

I get this error if I refresh the page too quickly, otherwise it works fine.

@GrahamCampbell

This comment has been minimized.

Show comment
Hide comment
@GrahamCampbell

GrahamCampbell Oct 9, 2016

Member

I get this error if I refresh the page too quickly

That's because you forgot to cache the config.

Member

GrahamCampbell commented Oct 9, 2016

I get this error if I refresh the page too quickly

That's because you forgot to cache the config.

@kristianvanessen

This comment has been minimized.

Show comment
Hide comment
@kristianvanessen

kristianvanessen Oct 13, 2016

use in command copy .env.example .env because you are missing the .env file. at least it worked for me.
and then use the generate key command.

use in command copy .env.example .env because you are missing the .env file. at least it worked for me.
and then use the generate key command.

@taksunil

This comment has been minimized.

Show comment
Hide comment
@taksunil

taksunil Oct 19, 2016

Steps to solve this problem.

  1. Create .env file using this command (copy .env.example .env)
  2. Run command (php artisan key:generate)

taksunil commented Oct 19, 2016

Steps to solve this problem.

  1. Create .env file using this command (copy .env.example .env)
  2. Run command (php artisan key:generate)
@karthigamahe

This comment has been minimized.

Show comment
Hide comment
@karthigamahe

karthigamahe Oct 19, 2016

Hi i m having the error while i running laravel.

RuntimeException in compiled.php line 13231: The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.

Hi i m having the error while i running laravel.

RuntimeException in compiled.php line 13231: The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.

@crisshnangularjs

This comment has been minimized.

Show comment
Hide comment
@crisshnangularjs

crisshnangularjs Oct 21, 2016

  1. php artisan key:generate
  2. the key which is generated, add that to your env file as APP_KEY = [generated_key]
  1. php artisan key:generate
  2. the key which is generated, add that to your env file as APP_KEY = [generated_key]
@lawalstephen

This comment has been minimized.

Show comment
Hide comment
@lawalstephen

lawalstephen Oct 25, 2016

In my own case the following was what worked

  1. ensure you have .env file if not rename the .env.example to .env
  2. run the command php artisan key:generate

In my own case the following was what worked

  1. ensure you have .env file if not rename the .env.example to .env
  2. run the command php artisan key:generate
@mrsimonbennett

This comment has been minimized.

Show comment
Hide comment
@mrsimonbennett

mrsimonbennett Nov 1, 2016

If you get this error and using artisan serve, once you fix the .env issue restart the process

If you get this error and using artisan serve, once you fix the .env issue restart the process

@tublitzed

This comment has been minimized.

Show comment
Hide comment
@tublitzed

tublitzed Nov 12, 2016

using $_ENV as a default in the event that the .env file hasn't been loaded yet fixed it for me:

'key' => env('APP_KEY', $_ENV['APP_KEY'])

tublitzed commented Nov 12, 2016

using $_ENV as a default in the event that the .env file hasn't been loaded yet fixed it for me:

'key' => env('APP_KEY', $_ENV['APP_KEY'])

@kolczu

This comment has been minimized.

Show comment
Hide comment
@kolczu

kolczu Dec 1, 2016

php artisan key:generate

kolczu commented Dec 1, 2016

php artisan key:generate

@alftonic

This comment has been minimized.

Show comment
Hide comment
@alftonic

alftonic Dec 9, 2016

Edit and Delete modal window its come good, but the action it's not working... thank you on advance!

alftonic commented Dec 9, 2016

Edit and Delete modal window its come good, but the action it's not working... thank you on advance!

@mehranrasulian

This comment has been minimized.

Show comment
Hide comment
@mehranrasulian

mehranrasulian Dec 14, 2016

For me, adding a new .env.testing file and running phpunit cause to this error:

RuntimeException: The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.

For me, adding a new .env.testing file and running phpunit cause to this error:

RuntimeException: The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.
@Share-Man

This comment has been minimized.

Show comment
Hide comment
@Share-Man

Share-Man Dec 30, 2016

Thank u and it's work!

Thank u and it's work!

@alftonic

This comment has been minimized.

Show comment
Hide comment
@alftonic

alftonic Dec 30, 2016

@knuks

This comment has been minimized.

Show comment
Hide comment
@knuks

knuks Jan 11, 2017

thank you all 100% working properly

knuks commented Jan 11, 2017

thank you all 100% working properly

@alftonic

This comment has been minimized.

Show comment
Hide comment
@alftonic

alftonic Jan 11, 2017

@rojasjandro89

This comment has been minimized.

Show comment
Hide comment
@rojasjandro89

rojasjandro89 Jan 14, 2017

'key' => env('APP_KEY', $_ENV['APP_KEY'])

That fixed it for me

'key' => env('APP_KEY', $_ENV['APP_KEY'])

That fixed it for me

@Acrunam

This comment has been minimized.

Show comment
Hide comment
@Acrunam

Acrunam Jan 17, 2017

It all depends on how you copy the key, e.g.

$ php artisan key:generate --show

gives you:

←[33mbase64:RGHTRHHdrg34984jrgg894g45gj5j54igYR6=←[39m

but what you type in as your key is (you leave out some of the starting and ending characters):

mbase64:RGHTRHHdrg34984jrgg894g45gj5j54igYR6

Acrunam commented Jan 17, 2017

It all depends on how you copy the key, e.g.

$ php artisan key:generate --show

gives you:

←[33mbase64:RGHTRHHdrg34984jrgg894g45gj5j54igYR6=←[39m

but what you type in as your key is (you leave out some of the starting and ending characters):

mbase64:RGHTRHHdrg34984jrgg894g45gj5j54igYR6

@lherich lherich referenced this issue in InfyOmLabs/adminlte-generator Jan 17, 2017

Closed

Open Generator Builder #8

@claytonrcarter

This comment has been minimized.

Show comment
Hide comment
@claytonrcarter

claytonrcarter Jan 18, 2017

Comment by @mehranrasulian pointed me in the right direction.

Everything worked simply and flawlessly until I created a .env.testing to support a CI pipeline I was working on. I was unaware that this file would be treated specially, but it turns out that the docs say that values in .env.testing will override values in .env when running PHPUnit.

I fixed the error by copying my development key (the whole APP_KEY line from .env) into the .env.testing file and the error went away.

Comment by @mehranrasulian pointed me in the right direction.

Everything worked simply and flawlessly until I created a .env.testing to support a CI pipeline I was working on. I was unaware that this file would be treated specially, but it turns out that the docs say that values in .env.testing will override values in .env when running PHPUnit.

I fixed the error by copying my development key (the whole APP_KEY line from .env) into the .env.testing file and the error went away.

@edisonan

This comment has been minimized.

Show comment
Hide comment
@edisonan

edisonan Jan 21, 2017

you need to set the .env file : APP_KEY properties set 32 characters

edisonan commented Jan 21, 2017

you need to set the .env file : APP_KEY properties set 32 characters

@hafizshahid

This comment has been minimized.

Show comment
Hide comment
@hafizshahid

hafizshahid Jan 23, 2017

In my case, I have run these two commands and it works fine.
1-
php artisan key:generate

2-
php artisan config:cache

hafizshahid commented Jan 23, 2017

In my case, I have run these two commands and it works fine.
1-
php artisan key:generate

2-
php artisan config:cache

@aliusa

This comment has been minimized.

Show comment
Hide comment
@aliusa

aliusa Feb 8, 2017

This worked for me:

  1. Create .env file in main directory
  2. Copy everything from .env.example (https://github.com/laravel/laravel/blob/master/.env.example)
  3. Run php artisan key:generate

aliusa commented Feb 8, 2017

This worked for me:

  1. Create .env file in main directory
  2. Copy everything from .env.example (https://github.com/laravel/laravel/blob/master/.env.example)
  3. Run php artisan key:generate
@LeandroRafaelF

This comment has been minimized.

Show comment
Hide comment
@LeandroRafaelF

LeandroRafaelF Feb 21, 2017

👍 Thanks for the help guys.

👍 Thanks for the help guys.

@sneakyimp

This comment has been minimized.

Show comment
Hide comment
@sneakyimp

sneakyimp Feb 22, 2017

It's pretty disappointing that no attempt is made here to explain why one would want to run artisan key:generate. No attempt is made to explain what this does, why it must be done, or whether the values and/or files it may generate should be the same or different on a dev machine versus a production machine et. al.

Are these values sensitive? Do they affect sessions or other functionality within the framework? What files are changed?

sneakyimp commented Feb 22, 2017

It's pretty disappointing that no attempt is made here to explain why one would want to run artisan key:generate. No attempt is made to explain what this does, why it must be done, or whether the values and/or files it may generate should be the same or different on a dev machine versus a production machine et. al.

Are these values sensitive? Do they affect sessions or other functionality within the framework? What files are changed?

@maynagashev

This comment has been minimized.

Show comment
Hide comment
@maynagashev

maynagashev Feb 24, 2017

@sneakyimp Application key affects session hashes and "other encrypted data" (as it's said in docs), I think it might be the same as on dev and production, only if it is not exposed anywhere in public. In that case theoretically you will be able to transfer session records between environments and they will match, because the was created (signed) with the same application key.

The need to generate a key (if it's not already generated by installer) listed in the installation section of documentation: https://laravel.com/docs/5.4/installation#configuration

@sneakyimp Application key affects session hashes and "other encrypted data" (as it's said in docs), I think it might be the same as on dev and production, only if it is not exposed anywhere in public. In that case theoretically you will be able to transfer session records between environments and they will match, because the was created (signed) with the same application key.

The need to generate a key (if it's not already generated by installer) listed in the installation section of documentation: https://laravel.com/docs/5.4/installation#configuration

@BodikSilver

This comment has been minimized.

Show comment
Hide comment
@BodikSilver

BodikSilver Mar 18, 2017

so what I must do for resolve this problem?

so what I must do for resolve this problem?

@mikerockett

This comment has been minimized.

Show comment
Hide comment
@BodikSilver

This comment has been minimized.

Show comment
Hide comment
@BodikSilver

BodikSilver Mar 18, 2017

Idon't know how? but after restart my laptop it work

Idon't know how? but after restart my laptop it work

@poncianodiego

This comment has been minimized.

Show comment
Hide comment
@poncianodiego

poncianodiego Mar 20, 2017

php artisan key:generate worked!

php artisan key:generate worked!

@motia

This comment has been minimized.

Show comment
Hide comment
@motia

motia Mar 25, 2017

@BodikSilver, I just faced the issue and solved it. Just add a slash to your key after base64: in your key that it looks like that:

APP_KEY=base64:/h4k6fjT8lmQ60lUXpGrPqJzFRBmMllYS2TJRLBEz1c=

motia commented Mar 25, 2017

@BodikSilver, I just faced the issue and solved it. Just add a slash to your key after base64: in your key that it looks like that:

APP_KEY=base64:/h4k6fjT8lmQ60lUXpGrPqJzFRBmMllYS2TJRLBEz1c=

@vahidrezaei

This comment has been minimized.

Show comment
Hide comment
@vahidrezaei

vahidrezaei Apr 1, 2017

hi
my problem is :
capture
pls help me.

hi
my problem is :
capture
pls help me.

@mikerockett

This comment has been minimized.

Show comment
Hide comment
@mikerockett

mikerockett Apr 1, 2017

@vahidrezaei Your issue is not relevant to this one. Please open a new issue at the Telegram SDK repo.

@vahidrezaei Your issue is not relevant to this one. Please open a new issue at the Telegram SDK repo.

@rappasoft rappasoft referenced this issue in rappasoft/laravel-5-boilerplate Apr 7, 2017

Closed

I got this error message when installing #671

@mdshohelrana

This comment has been minimized.

Show comment
Hide comment
@mdshohelrana

mdshohelrana Apr 8, 2017

--to sample project

  1. create a new project by the name of command ' laravel new projectname '
  2. php artisan key:generate

--to your project
3. copy .env.example .env
4. copy the key from sample project to your project APP_KEY=base64:s73yn+HBscYlSivoHPeNCntMwM8v2WCnrqJI8BUOQSQ=
5. php artisan config:clear
6. php artisan config:cache
7. php artisan key:generate

I think this would be helpful to you.

--to sample project

  1. create a new project by the name of command ' laravel new projectname '
  2. php artisan key:generate

--to your project
3. copy .env.example .env
4. copy the key from sample project to your project APP_KEY=base64:s73yn+HBscYlSivoHPeNCntMwM8v2WCnrqJI8BUOQSQ=
5. php artisan config:clear
6. php artisan config:cache
7. php artisan key:generate

I think this would be helpful to you.

@pimski

This comment has been minimized.

Show comment
Hide comment
@pimski

pimski May 10, 2017

Same as @mikerockett. The error only occurs every once in a while (I've only seen it in AJAX requests so far).

I have version 5.4.19 (not upgraded from a previous version)
APP_KEY is set in .env (was set during installation)

The strange thing is, the error says "production.ERROR" even though I'm back in local mode. I have tried production mode (with config:cache) but I'm now back to local. I have also done "php artisan config:clear" since.

Piece of the error:

[2017-05-10 09:52:55] production.ERROR: RuntimeException: The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths. in C:\project\vendor\laravel\framework\src\Illuminate\Encryption\Encrypter.php:43
Stack trace:
#0 C:\project\vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php(27): Illuminate\Encryption\Encrypter->__construct('', 'AES-256-CBC')
#1 C:\project\vendor\laravel\framework\src\Illuminate\Container\Container.php(716): Illuminate\Encryption\EncryptionServiceProvider->Illuminate\Encryption\{closure}(Object(Illuminate\Foundation\Application), Array)
#2 C:\project\vendor\laravel\framework\src\Illuminate\Container\Container.php(598): Illuminate\Container\Container->build(Object(Closure))

pimski commented May 10, 2017

Same as @mikerockett. The error only occurs every once in a while (I've only seen it in AJAX requests so far).

I have version 5.4.19 (not upgraded from a previous version)
APP_KEY is set in .env (was set during installation)

The strange thing is, the error says "production.ERROR" even though I'm back in local mode. I have tried production mode (with config:cache) but I'm now back to local. I have also done "php artisan config:clear" since.

Piece of the error:

[2017-05-10 09:52:55] production.ERROR: RuntimeException: The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths. in C:\project\vendor\laravel\framework\src\Illuminate\Encryption\Encrypter.php:43
Stack trace:
#0 C:\project\vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php(27): Illuminate\Encryption\Encrypter->__construct('', 'AES-256-CBC')
#1 C:\project\vendor\laravel\framework\src\Illuminate\Container\Container.php(716): Illuminate\Encryption\EncryptionServiceProvider->Illuminate\Encryption\{closure}(Object(Illuminate\Foundation\Application), Array)
#2 C:\project\vendor\laravel\framework\src\Illuminate\Container\Container.php(598): Illuminate\Container\Container->build(Object(Closure))
@pimski

This comment has been minimized.

Show comment
Hide comment
@pimski

pimski May 10, 2017

To elaborate my own situation :-)

It seems the .env file is locked during a request and can't be read by a simultanious other request. When the .env file can't be read the default settings (from the config dir) will be used. Hence the "production.ERROR" and the absense of the encryption key.

It seems config:cache solves the problem (since it bypasses the .env file). Haven't tried this though.

I think this functionality should have a big heads up in the laravel documentation. It can lead to strange bugs that occur randomly...

pimski commented May 10, 2017

To elaborate my own situation :-)

It seems the .env file is locked during a request and can't be read by a simultanious other request. When the .env file can't be read the default settings (from the config dir) will be used. Hence the "production.ERROR" and the absense of the encryption key.

It seems config:cache solves the problem (since it bypasses the .env file). Haven't tried this though.

I think this functionality should have a big heads up in the laravel documentation. It can lead to strange bugs that occur randomly...

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Jun 11, 2017

use this command

php artisan key:generate

ghost commented Jun 11, 2017

use this command

php artisan key:generate

@webchun

This comment has been minimized.

Show comment
Hide comment
@webchun

webchun Jun 12, 2017

I have the same problem, even when I run php artisan key:generate it also returned the same error. I fixed this by editing .env file and enter 32 random chars for APP_KEY (I use AES-256-CBC)

webchun commented Jun 12, 2017

I have the same problem, even when I run php artisan key:generate it also returned the same error. I fixed this by editing .env file and enter 32 random chars for APP_KEY (I use AES-256-CBC)

@aluferraz

This comment has been minimized.

Show comment
Hide comment
@aluferraz

aluferraz Jun 13, 2017

I have the same issue @pimski

Under a heavy load of requests, two async ajax requests are made, and during the second request the .env file is locked, so I receive the error only for that request.

To elaborate my own situation :-)

It seems the .env file is locked during a request and can't be read by a simultanious other request. When the .env file can't be read the default settings (from the config dir) will be used. Hence the "production.ERROR" and the absense of the encryption key.

It seems config:cache solves the problem (since it bypasses the .env file). Haven't tried this though.

I think this functionality should have a big heads up in the laravel documentation. It can lead to strange bugs that occur randomly...

I think this should be revised, because it is very common two have parallel requests.

I'm using WAMP on Windows 10, @pimski which OS/Webserver Stack are you using ?

aluferraz commented Jun 13, 2017

I have the same issue @pimski

Under a heavy load of requests, two async ajax requests are made, and during the second request the .env file is locked, so I receive the error only for that request.

To elaborate my own situation :-)

It seems the .env file is locked during a request and can't be read by a simultanious other request. When the .env file can't be read the default settings (from the config dir) will be used. Hence the "production.ERROR" and the absense of the encryption key.

It seems config:cache solves the problem (since it bypasses the .env file). Haven't tried this though.

I think this functionality should have a big heads up in the laravel documentation. It can lead to strange bugs that occur randomly...

I think this should be revised, because it is very common two have parallel requests.

I'm using WAMP on Windows 10, @pimski which OS/Webserver Stack are you using ?

@devcircus

This comment has been minimized.

Show comment
Hide comment
@devcircus

devcircus Jun 13, 2017

Contributor

Cache your configuration and don't use env outside your config files. Shouldn't use env in production except from config.

Contributor

devcircus commented Jun 13, 2017

Cache your configuration and don't use env outside your config files. Shouldn't use env in production except from config.

@aluferraz

This comment has been minimized.

Show comment
Hide comment
@aluferraz

aluferraz Jun 18, 2017

Ok, I see that doing config:cache in a Laravel Application solves the problem, but in a Lumen Application the .env file seems to be the only way:

https://lumen.laravel.com/docs/5.4/configuration

There is no "config caching".. I've even tried to copy the config:cache artisan command, but the cached file has no effect ... Lumen is always trying to access the .env file..

Any ideas ?

aluferraz commented Jun 18, 2017

Ok, I see that doing config:cache in a Laravel Application solves the problem, but in a Lumen Application the .env file seems to be the only way:

https://lumen.laravel.com/docs/5.4/configuration

There is no "config caching".. I've even tried to copy the config:cache artisan command, but the cached file has no effect ... Lumen is always trying to access the .env file..

Any ideas ?

@tomiwatech

This comment has been minimized.

Show comment
Hide comment
@tomiwatech

tomiwatech Jun 22, 2017

I was using 'key' => env('Wd8ixPMi0t89o+bCZHkjQvL8ljkWSLwJLPlhEArWick') instead of
'key' => env('APP_KEY','Wd8ixPMi0t89o+bCZHkjQvL8ljkWSLwJLPlhEArWick'). so using
'key' => env('APP_KEY','Wd8ixPMi0t89o+bCZHkjQvL8ljkWSLwJLPlhEArWick') finished the job for me

Besides this guide demystified my installation process
https://tecadmin.net/install-laravel-framework-on-ubuntu/#

I was using 'key' => env('Wd8ixPMi0t89o+bCZHkjQvL8ljkWSLwJLPlhEArWick') instead of
'key' => env('APP_KEY','Wd8ixPMi0t89o+bCZHkjQvL8ljkWSLwJLPlhEArWick'). so using
'key' => env('APP_KEY','Wd8ixPMi0t89o+bCZHkjQvL8ljkWSLwJLPlhEArWick') finished the job for me

Besides this guide demystified my installation process
https://tecadmin.net/install-laravel-framework-on-ubuntu/#

@congjie

This comment has been minimized.

Show comment
Hide comment
@congjie

congjie Jun 27, 2017

php artisan key:generate then restart php artisan ser

congjie commented Jun 27, 2017

php artisan key:generate then restart php artisan ser

@lloricode

This comment has been minimized.

Show comment
Hide comment
@lloricode

lloricode Jul 7, 2017

work's fine, Thanks

language: php

php:
  - 5.6

before_script:
  - cp .env.travis .env
  - mysql -e 'create database homestead_test;'
  - composer self-update
  - composer install --no-interaction
  - php artisan migrate
  - php artisan key:generate
  - php artisan config:clear
  - php artisan config:cache

# script:
# - phpunit

config

work's fine, Thanks

language: php

php:
  - 5.6

before_script:
  - cp .env.travis .env
  - mysql -e 'create database homestead_test;'
  - composer self-update
  - composer install --no-interaction
  - php artisan migrate
  - php artisan key:generate
  - php artisan config:clear
  - php artisan config:cache

# script:
# - phpunit

config

@KrisRoofe

This comment has been minimized.

Show comment
Hide comment
@morshud

This comment has been minimized.

Show comment
Hide comment
@morshud

morshud Aug 20, 2017

i have the same issue but i try
php artisan key:generate
and resart your php artisan serve
then it works

morshud commented Aug 20, 2017

i have the same issue but i try
php artisan key:generate
and resart your php artisan serve
then it works

Odd-Tablet added a commit to Odd-Tablet/Laravel-Test that referenced this issue Aug 21, 2017

@pwaring

This comment has been minimized.

Show comment
Hide comment
@pwaring

pwaring Aug 23, 2017

Three things I've noticed that are bugs in this behaviour and took me a while to work out:

  1. php artisan key:generate will say that it has set the application key successfully even if it hasn't.
  2. You must have a line APP_KEY= in your .env - key:generate won't add this for you.
  3. key:generate will append to, rather than replace, APP_KEY. If you run key:generate multiple times, you'll end up with a long key that doesn't work.

pwaring commented Aug 23, 2017

Three things I've noticed that are bugs in this behaviour and took me a while to work out:

  1. php artisan key:generate will say that it has set the application key successfully even if it hasn't.
  2. You must have a line APP_KEY= in your .env - key:generate won't add this for you.
  3. key:generate will append to, rather than replace, APP_KEY. If you run key:generate multiple times, you'll end up with a long key that doesn't work.
@mmsa

This comment has been minimized.

Show comment
Hide comment
@mmsa

mmsa Aug 23, 2017

  1. run php artisan key:generate if you received
    [ErrorException] file_get_contents(/.env): failed to op en stream: No such file or directory
    You need to rename .env.example to .env in the application root

mmsa commented Aug 23, 2017

  1. run php artisan key:generate if you received
    [ErrorException] file_get_contents(/.env): failed to op en stream: No such file or directory
    You need to rename .env.example to .env in the application root
@svengit

This comment has been minimized.

Show comment
Hide comment
@svengit

svengit Aug 31, 2017

This is still an issue. Fresh install from yesterday (Laravel 5.4).
I cannot get it to work with the key in .env. It has to be either in config/app.php or the config has to be cached, both no viable solutions.

Edit: I feel a bit dumb now. .env was not readable. Might be good to produce at least a warning when this happens 'Warning: .env exists but cannot be read' or something like that

svengit commented Aug 31, 2017

This is still an issue. Fresh install from yesterday (Laravel 5.4).
I cannot get it to work with the key in .env. It has to be either in config/app.php or the config has to be cached, both no viable solutions.

Edit: I feel a bit dumb now. .env was not readable. Might be good to produce at least a warning when this happens 'Warning: .env exists but cannot be read' or something like that

@JonMadVal

This comment has been minimized.

Show comment
Hide comment
@JonMadVal

JonMadVal Sep 14, 2017

Hi i changed the value of the 'key' parameter in app.php for the value of the APP_KEY in the .env file like this:
OLD: 'key' =>'env('APP_KEY')'
NEW : 'key' =>'base64:ybs4GNU0vR4bmJVAJx+c82nFIpbJ3cHop4dwcS3QTe*(',

Thats work for me.

Hi i changed the value of the 'key' parameter in app.php for the value of the APP_KEY in the .env file like this:
OLD: 'key' =>'env('APP_KEY')'
NEW : 'key' =>'base64:ybs4GNU0vR4bmJVAJx+c82nFIpbJ3cHop4dwcS3QTe*(',

Thats work for me.

@rs-sliske

This comment has been minimized.

Show comment
Hide comment
@rs-sliske

rs-sliske Sep 14, 2017

@JonMadVal while that technically works, that isnt really a secure solution

one of the reasons that key, along with database/service credentials are in the .env file is that they shouldnt be included in your source control, which by default at least, config files are, .env is not

it would be far better to look into why it failed to read the value from .env, which is likely to either be a file permissions issue, or a caching issue (try running artisan config:clear)

@JonMadVal while that technically works, that isnt really a secure solution

one of the reasons that key, along with database/service credentials are in the .env file is that they shouldnt be included in your source control, which by default at least, config files are, .env is not

it would be far better to look into why it failed to read the value from .env, which is likely to either be a file permissions issue, or a caching issue (try running artisan config:clear)

@JonMadVal

This comment has been minimized.

Show comment
Hide comment
@JonMadVal

JonMadVal Sep 14, 2017

@rs-sliske for sure is not a secure solution but any of the above solutions works for me, i tried changed the permissions file, i executed the config:clear command, re-build the key but does't works.

maybe the weekend i can work on it and looks for the optimal solution.

If you have some idea to tried i'll glad to know it, i'm running laravel fedora.

Thanks

@rs-sliske for sure is not a secure solution but any of the above solutions works for me, i tried changed the permissions file, i executed the config:clear command, re-build the key but does't works.

maybe the weekend i can work on it and looks for the optimal solution.

If you have some idea to tried i'll glad to know it, i'm running laravel fedora.

Thanks

@vincurekf

This comment has been minimized.

Show comment
Hide comment
@vincurekf

vincurekf Nov 15, 2017

I have the same issue, on Laravel 5.4.*, I am getting:

local.ERROR: exception 'RuntimeException' with message 'The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.'

and

local.ERROR: exception 'PDOException' with message 'SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO)'

Putting APP_KEY and DB_* values directly in config/app.php and config/database.php solved the issue, but I don't think this is the best solution.

I have .env file with permissions 0744 and all variables mentioned above set correctly.

Other than setting values directly in config files, I've tried all solutions suggested above:

php artisan key:generate
php artisan config:clear

with no permanent effect, the error pops up randomly, most with ajax requests (eg. uploading multiple files, where 3 of 4 files are uploaded, the 4th returns one of the errors)

When I try config:cache after key:generate I get:

local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Cannot redeclare class App\__'

One think to notice, I am running these commands from a route:

Route::get('/clear-fix', function() {
    $this->middleware('auth');
    $exitCode = Artisan::call('key:generate');
    $exitCode = $exitCode == 0 ? Artisan::call('config:clear') : $exitCode;
    $exitCode = $exitCode == 0 ? Artisan::call('config:cache') : $exitCode;
    return $exitCode;
});

I have the same issue, on Laravel 5.4.*, I am getting:

local.ERROR: exception 'RuntimeException' with message 'The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.'

and

local.ERROR: exception 'PDOException' with message 'SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO)'

Putting APP_KEY and DB_* values directly in config/app.php and config/database.php solved the issue, but I don't think this is the best solution.

I have .env file with permissions 0744 and all variables mentioned above set correctly.

Other than setting values directly in config files, I've tried all solutions suggested above:

php artisan key:generate
php artisan config:clear

with no permanent effect, the error pops up randomly, most with ajax requests (eg. uploading multiple files, where 3 of 4 files are uploaded, the 4th returns one of the errors)

When I try config:cache after key:generate I get:

local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Cannot redeclare class App\__'

One think to notice, I am running these commands from a route:

Route::get('/clear-fix', function() {
    $this->middleware('auth');
    $exitCode = Artisan::call('key:generate');
    $exitCode = $exitCode == 0 ? Artisan::call('config:clear') : $exitCode;
    $exitCode = $exitCode == 0 ? Artisan::call('config:cache') : $exitCode;
    return $exitCode;
});
@kennblvnp

This comment has been minimized.

Show comment
Hide comment
@kennblvnp

kennblvnp Jan 8, 2018

Mine works using this:

  1. composer update
  2. php artisan key:generate
  3. php artisan config:clear
  4. php artisan config:cache

Mine works using this:

  1. composer update
  2. php artisan key:generate
  3. php artisan config:clear
  4. php artisan config:cache
@PeiyuanQi

This comment has been minimized.

Show comment
Hide comment
@PeiyuanQi

PeiyuanQi Mar 26, 2018

I think the cause of the problem is there is no proper key cached.
In my situation, I solved it by performing the following procedures:
If you have ignored the .env file, which you should, then just do the following things:

  1. Make sure you have .env, create one by cp .env.example .env
  2. Generate new key by php artisan key:generate
  3. Clear cache and cache new key by php artisan config:cache

Hope it works for you.

PeiyuanQi commented Mar 26, 2018

I think the cause of the problem is there is no proper key cached.
In my situation, I solved it by performing the following procedures:
If you have ignored the .env file, which you should, then just do the following things:

  1. Make sure you have .env, create one by cp .env.example .env
  2. Generate new key by php artisan key:generate
  3. Clear cache and cache new key by php artisan config:cache

Hope it works for you.

@TomRosenbloom

This comment has been minimized.

Show comment
Hide comment
@TomRosenbloom

TomRosenbloom Apr 20, 2018

Here is a simplistic explanation of how this Laravel/Heroku API key business works, according to my understanding and how I managed to get it working:

  • When you create a new laravel application, an APP_KEY constant is created in .env
  • Your Heroku deployment of the Laravel app must have the same key
  • You can set/update the key that Heroku has via the Heroku dashboard, OR you can set it via the command line with 'heroku config:set APP_KEY=...'
  • The form of the key is 'base64:' followed by 43 characters and an equals sign (I think this is right, anyway the important thing is that you include the whole thing - initially I mistakenly left off the 'base64:' part)

I found the official documentation to be unclear. You are told to use artisan to generate a key, but my understanding is that (1) you don't need to do this because a key will have been created (by Composer) during creation of the laravel application (2) if you do use artisan to generate a key you would need to manually insert this key into the laravel .env file as well as supplying it to Heroku since it will be different from the one you currently have in .env (perhaps in some environments the artisan generate command updates .env?)

Here is a simplistic explanation of how this Laravel/Heroku API key business works, according to my understanding and how I managed to get it working:

  • When you create a new laravel application, an APP_KEY constant is created in .env
  • Your Heroku deployment of the Laravel app must have the same key
  • You can set/update the key that Heroku has via the Heroku dashboard, OR you can set it via the command line with 'heroku config:set APP_KEY=...'
  • The form of the key is 'base64:' followed by 43 characters and an equals sign (I think this is right, anyway the important thing is that you include the whole thing - initially I mistakenly left off the 'base64:' part)

I found the official documentation to be unclear. You are told to use artisan to generate a key, but my understanding is that (1) you don't need to do this because a key will have been created (by Composer) during creation of the laravel application (2) if you do use artisan to generate a key you would need to manually insert this key into the laravel .env file as well as supplying it to Heroku since it will be different from the one you currently have in .env (perhaps in some environments the artisan generate command updates .env?)

@devcircus

This comment has been minimized.

Show comment
Hide comment
@devcircus

devcircus Apr 20, 2018

Contributor

The .env file is updated every time you run the command. The only time the key is automatically created for you is when you run "laravel new" to create an app. Anytime you clone a repo or begin a project another way, you'll need to run that command. Then, no matter what hosting service you use, you'll have to set the key on the server to match the key that was generated.

Contributor

devcircus commented Apr 20, 2018

The .env file is updated every time you run the command. The only time the key is automatically created for you is when you run "laravel new" to create an app. Anytime you clone a repo or begin a project another way, you'll need to run that command. Then, no matter what hosting service you use, you'll have to set the key on the server to match the key that was generated.

@TomRosenbloom

This comment has been minimized.

Show comment
Hide comment
@TomRosenbloom

TomRosenbloom Apr 20, 2018

That makes sense, and that's how I would have expected it to work, but on my (Windows) local machine running the command doesn't update the .env file.

That makes sense, and that's how I would have expected it to work, but on my (Windows) local machine running the command doesn't update the .env file.

@Cholowao

This comment has been minimized.

Show comment
Hide comment
@Cholowao

Cholowao May 10, 2018

You need to have .env on your appication folder then run:

$ php artisan key:generate
If you don't have .env copy from .env.example:

$ cp .env.example .env

You need to have .env on your appication folder then run:

$ php artisan key:generate
If you don't have .env copy from .env.example:

$ cp .env.example .env

@zymawy zymawy referenced this issue in sazanrjb/OfficeManagementSystem Jun 17, 2018

Closed

avoiding RuntimeException #5

@hu-qi

This comment has been minimized.

Show comment
Hide comment
@hu-qi

hu-qi Jun 26, 2018

The method is correct as @shakirblouch ,thanks!
run

php artisan key:generate

then run

php artisan config:clear

my version
php 5.6.36
laravel 5.3.*
window 10

hu-qi commented Jun 26, 2018

The method is correct as @shakirblouch ,thanks!
run

php artisan key:generate

then run

php artisan config:clear

my version
php 5.6.36
laravel 5.3.*
window 10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment