susanne99's avatar

EncryptionServiceProvider.php -> $config['key'] is sometimes null - really !!

Laravel Version 11.19.0

PHP Version 8.3.10

I use Laravel 11 as the backend for the middleware. Frontend is a SPA VUE application. For authentication I use Laravel Sanctum. Problem description: it happens sometimes, during the app runs, that the "app_key" is not defined That's wrong, otherwise it would never work. However, I noticed that in the class "EncryptionServiceProvider" the method "key" with "$config" as a parameter, where the "key" member is really "null". The interesting thing is that all other .env (APP_) entries are there, only the "key" entry is null !!!! What's going on - unfortunately this makes the application completely unstable and unusable

protected function key(array $config) { return tap($config['key'], function ($key) { if (empty($key)) { throw new MissingAppKeyException; } }); }

**here the code where th error occurs: file: \vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php

` protected function registerEncrypter() { $this->app->singleton('encrypter', function ($app) { $config = $app->make('config')->get('app');

return (new Encrypter($this->parseKey($config), $config['cipher']))
    ->previousKeys(array_map(
        fn ($key) => $this->parseKey(['key' => $key]),
        $config['previous_keys'] ?? []
    ));

}); }`** after this command $config = $app->make('config')->get('app'); the $config['key'] is null or empty

Important Hint: $config['key'] is not always null, and it is the only only member of config that is destroyed !!!!!!!!!!!!!!!!!

laravel runs on windows 10 with latest XAMPP

0 likes
0 replies

Please or to participate in this conversation.