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

lamboap's avatar

php artisan optimize

I was getting an error when running this command

> php artisan optimize


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

because I was missing my .env file. If I run php artisan config:cache artisan optimize will work without the .env file. because the cached values are in /bootstrap/cache/config.php

On another project I tried the same thing, mv the .env file and ran php artisan optimize expecting the build to fail, but it didnt. cd'ing into /bootstrap/cache I did not see a config.php .

My question is: where else does artisan look for the app_key and app_debug status if the .env file is missing?

0 likes
4 replies
SaeedPrez's avatar

You can try do php artisan key:generate as it seems your key is flawed.

lamboap's avatar

@SaeedPrez that's the thing. I was able to optimize without an .env file which is where the key is. is there another location where the key could be besides the /cache/config.php file?

ivanhoe011's avatar

You can also push your env variables from web server, without using .env files

Please or to participate in this conversation.