framework APP_KEY not cached unless config:cache is run twice PHP

  • Laravel Version: 8.42.1
  • PHP Version: 7.4.3

Description:

In one of our automated deployment processes for a pre-production environment, we have had a strange issue in the way that APP_KEY is cached. We always deploy from a clean checkout of the repository (symlinking to a persistent storage directory, but with a clean bootstrap/cache folder), and in the last steps of the process we run key:generate and cache:config.

We're noticing that if we only run cache:config once, the bootstrap/cache/config.php file will not have the APPKEY value cached (key will just have '') - all other values are cached just fine (e.g. database passwords and so on). If we run cache:config again (without touching anything else or running any other commands), then it will have the APPKEY value correctly cached.

Any ideas as to why we'd need to run config:cache twice? It does work this way, but it feels wrong :-).

Steps To Reproduce:

If at the end of our deployment process we run the below commands, bootstrap/cache/config.php will not have APP_KEY cached (but will have everything else cached just fine).

php artisan migrate --force --seed
php artisan cache:clear
php artisan view:clear
php artisan route:clear
php artisan key:generate
umask 0007
php artisan config:cache
php artisan up
sudo /usr/sbin/service php7.4-fpm reload

If we change it so it runs config:cache twice, it will have APP_KEY cached:

php artisan migrate --force --seed
php artisan cache:clear
php artisan view:clear
php artisan route:clear
php artisan key:generate
umask 0007
php artisan config:cache
php artisan config:cache
php artisan up
sudo /usr/sbin/service php7.4-fpm reload
Asked Oct 08 '21 06:10
avatar bluezio
bluezio

1 Answer:

Hi there,

Thanks for reporting but it looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repo you can try one of the following channels:

However, this issue will not be locked and everyone is still free to discuss solutions to your problem!

Thanks.

1
Answered Aug 05 '21 at 07:58
avatar  of driesvints
driesvints