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.
"Freek’s newsletter is one of the best ways to stay updated with the Laravel and PHP ecosystem. It consistently highlights useful packages, tools, and ideas from the community, especially the amazing work coming from Spatie. As a Laravel developer building SaaS and web platforms, I find it extremely helpful to discover practical tools and insights that improve my development workflow."