Framework: Is env function delayed?

Created on 28 Jul 2016  路  6Comments  路  Source: laravel/framework

Well, whenever I google about this error

[2016-07-27 15:29:08] local.ERROR: RuntimeException: No supported encrypter found. The cipher and / or key length are invalid. in C:...\vendor\laravelframework\src\Illuminate\Encryption\EncryptionServiceProvider.php:29

I found it is needed to regenerate a valid 32-length hash for AES-256-CBC. Okay, it's right.

However, I thought the ENV may be delaying to retrieve the custom data from the .env file. Because it appears again sometimes. Look at config/app.php for:

'key' => env('APP_KEY', 'someDifferentKeyFromTheDotEnvFile'),

Is it possible to decrypt the session with the wrong key at runtime?

Would OPCACHE improve that .env file reading? Is it any to do with config:cache for improvement?

Thanks in advance!

Most helpful comment

Once the config is cached, we skip reading the .env file entirely. As well as improving performance, it also fixes issues with environment variables leaking through threads.

All 6 comments

Thanks for getting in touch. You just need to run the config:cache command to persist any config updates. :)

Once the config is cached, we skip reading the .env file entirely. As well as improving performance, it also fixes issues with environment variables leaking through threads.

Thank you so, @GrahamCampbell
Whether it's possible... so I'm not crazy :laughing: I'll rely on config:cache to solve the leaking.

Hey guys, I'm having this issue from time to time. It's totally random. Every few requests, it fails reading the key from the .env file, but most of the request go through with no problems.

Running config:cache seems to do the trick, but this is on a development machine.

Is there any other way to get around this than running config:cache periodically?

No, sorry. This is a bug inherit to the way PHP works. Probably a no-fix. :(

Cool, no problem. Thank you!

What should I search for if I want to learn more about this issue with PHP?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jackmu95 picture jackmu95  路  3Comments

shopblocks picture shopblocks  路  3Comments

lzp819739483 picture lzp819739483  路  3Comments

Fuzzyma picture Fuzzyma  路  3Comments

felixsanz picture felixsanz  路  3Comments