Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

susanne99's avatar

laravel 11 : missing APP_Key !!!!!!!!!!!!!!!!!!!!!!!!!

I upgraded to laravel 11. i use latest xampp on WIN11

From one request to the next the server loses the APP_KEY - not always but very often. It is definitely a bug in Laravel 11!!!

here the $config from vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php:33

GOOD REQUEST

Illuminate\Config\Repository {#36 // vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php:33 #items: array:24 [ 4 => "concurrency" "app" => array:17 [ "name" => "testSystem" "env" => "local" "debug" => true "url" => "http://localhost" "frontend_url" => "http://localhost:3000" "asset_url" => null "timezone" => "UTC" "locale" => "de" "fallback_locale" => "de" "faker_locale" => "de_DE" "cipher" => "AES-256-CBC" "key" => "base64:9Hv2YAAm2Gk5p6gNAJ3nIfVjMuyxDhR9K0pUbIORREU=" "previous_keys" => array:1 [ 0 => "base64:9Hv2YAAm2Gk5p6gNAJ3nIfVjMuyxDhR9K0pUbIORREU=" ] "maintenance" => array:2 [ "driver" => "file" "store" => "database" ] "providers" => array:28 [ 0 => "Illuminate\Auth\AuthServiceProvider" 1 => "Illuminate\Broadcasting\BroadcastServiceProvider" 2 => "Illuminate\Bus\BusServiceProvider" 3 => "Illuminate\Cache\CacheServiceProvider"

BAD REQUEST

Illuminate\Config\Repository {#36 // vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php:33 #items: array:24 [ 4 => "concurrency" "app" => array:17 [ "name" => "testSystem" "env" => "local" "debug" => false "url" => "http://localhost" "frontend_url" => "http://localhost:3000" "asset_url" => null "timezone" => "UTC" "locale" => "de" "fallback_locale" => "de" "faker_locale" => "de_DE" "cipher" => "AES-256-CBC" "key" => null "previous_keys" => [] "maintenance" => array:2 [ "driver" => "file" "store" => "database" ] "providers" => array:28 [ 0 => "Illuminate\Auth\AuthServiceProvider" 1 => "Illuminate\Broadcasting\BroadcastServiceProvider" 2 => "Illuminate\Bus\BusServiceProvider"

with laravel 8 and 10 it work's !!!

0 likes
10 replies
JussiMannisto's avatar

From one request to the next the server loses the APP_KEY - not always but very often. It is definitely a bug in Laravel 11!!!

I assure you it's not.

Leave out the excessive exclamation marks and curse words. Try to instead explain what you're doing.

Are you using InertiaJS? Did you follow Laravel's upgrade guide when upgrading?

2 likes
susanne99's avatar

yes, i did follow the upgrade guide. i don't use InertiaJS

I updated to Laravel 11. Since then it can sometimes no longer read the .env file. This means that he sometimes uses the default values, e.g. for the APP_KEY. I wrote my own blog about it. Strangely enough, my app works like this under debian/apache, now I thought I would adapt the files more to Laravel 11, for example: the bootstrap/app.php and others. Maybe reading out the config will work. well, and now the route list no longer works. Even if I remove the route with the missing class from the api.php, it doesn't find the class for the next route. I now have the file/folder organization again like it was with Laravel 8 and the route list works again. The incorrect config entries still don't work. In the file "laravel.../encyption/encyrptionserviceprovider.php" in line 82 the $config is set with default values ​​- no idea why - it's definitely annoying!!!!!!!!!

in file Env.php the function protected static function getOption($key) return sometimes null: $key = "APP_KEY" $t = static::getRepository()->get($key);

maybe it has something todo with the repository - look at this: https://laravel.com/docs/11.x/octane#configuration-repository-injection but i use injection, but not configuration injection, these are my singleton: $container = $this->app; $container->singleton(IBusinessServiceProvider::class, BusinessServiceProvider::class); $container->singleton(IStorageServiceProvider::class, StorageServiceProvider::class);

susanne99's avatar

Well, I think I've found the solution. If I delete the bootstrap/cache/config.php, then the crashes occur because it reads directly from the .env file. And the VLUCAS putenv and getenv apparently cannot do that because they are not thread safe. Question: how can you use such a library - either do it properly or not!! It has nothing to do with high-quality software. Well, times have changed, things were different 20-40 years ago - today it's just quicker and quicker

JussiMannisto's avatar

@susanne99

If I delete the bootstrap/cache/config.php, then the crashes occur because it reads directly from the .env file. And the VLUCAS putenv and getenv apparently cannot do that because they are not thread safe.

Absolute nonsense.

Usually people read the docs and try to understand how the framework works. You're free to do random changes instead and break your app. But don't then complain about it on a forum meant for learning. Write a blog or something.

susanne99's avatar

@JussiMannisto sorry, read the docu from vlucas, i get also the direct answer from him to may problem !! putenv and getenv are not thread safe. that means concurrent access is not working ! I use laravel as web api with async calls, and so on and so on .... I don't care whether you believe it or not, I've been in the IT for 40 years and it works now

Snapey's avatar

@susanne99 what most people do is follow advice and never directly access values in .env file. always read env into config files and cache it when in production.

Oh and if the docs page says Laravel Octane at the top, its probably not relevant to your issue!!!!!

experimentor's avatar

@susanne99 I've been in the IT business for 10 yrs only. In these 10 years I've learnt one very valuable lesson:

  • If a software is working for everyone but not me, it does not mean there is a bug in the software. It means I have done something wrong, or, I am utilising the software in ways that it is not intended for.

Another lesson:

  • Clear communication without sensationalisation (too many !!!!s) helps others to understand me better and help me better.

I could not understand the issue you are pointing to in these posts. Thread safety and concurrency are above my pay-grade. Maybe there is a genuine bug which normal users of laravel generally don't experience. Maybe it needs fixing. But your language is not helping in driving the clarity.

If you are sure that it is a genuine bug, please do post it as an issue in Laravel Github repo. And please do inform everyone here with some clear communication.

Lastly... Thank you for your service.

susanne99's avatar

@experimentor I think I've communicated clearly here, if you don't understand the problem, it's not my fault. Threadsafe and parallelism are just basics - sorry. If you don't understand that, you should do something else

Please or to participate in this conversation.