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

masterpowers's avatar

php artisan config:cache cant access my .env variable

Its Odd to Know that when i try to optimize my App using php artisan config:cache

it messes up the code , all env('$variable') returns null

but if you tried php artisan config:clear it will start to be used again...

Any Work Around here? ive read that using env() during config cache really returns null they say we need to change it to config() but im not getting any good result also

0 likes
2 replies
jlrdw's avatar

Are you in development or production if production you did see this line didn't you? Although Dotenv was not meant for production, I don't want to change our deployment and configuration workflow.

Please or to participate in this conversation.