It's very easy to port Laravel 5's way of handling environment files to Laravel 4.
You've got to require this package (it's that one that L5 uses):
[code]composer require vlucas/phpdotenv```
And then you should update bootstrap/start.php:
...
$dotEnv = new Dotenv\Dotenv(__DIR__ . '/../');
$dotEnv->load();
$env = $app->detectEnvironment(function () {
return getenv('APP_ENV') ?: 'production';
});
...
And boom, done! Now you can use an .env-file instead of .env.php.
Get my monthly newsletter with what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.
No spam. Unsubscribe anytime.
You can also follow me on X.
"I’ve been reading freeks newsletter for a while now, and it’s easily one of my favorite developer newsletters. Freek shares practical, no-nonsense insights from running Spatie, maintaining hundreds of open-source packages, and shipping real products.
Every time I get useful Laravel tips, smart tooling advice, always high quality and immediately applicable."