PHPackages                             jarnix/laravel-auto-environment - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jarnix/laravel-auto-environment

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jarnix/laravel-auto-environment
===============================

Auto-detection and configuration of the environment with multiple env files

1.0.6(8y ago)2578MITPHP

Since Feb 27Pushed 8y ago1 watchersCompare

[ Source](https://github.com/jarnix/laravel-auto-environment)[ Packagist](https://packagist.org/packages/jarnix/laravel-auto-environment)[ RSS](/packages/jarnix-laravel-auto-environment/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (4)Versions (8)Used By (0)

For Laravel 5+
--------------

[](#for-laravel-5)

Auto-detects the application environment with the hostname or http host
-----------------------------------------------------------------------

[](#auto-detects-the-application-environment-with-the-hostname-or-http-host)

Allows for multiple environments and versioned "env" files.
-----------------------------------------------------------

[](#allows-for-multiple-environments-and-versioned-env-files)

Detects the application environment from a env file or the hostname or http host. A .env file will always overwrite any other file (default Laravel's behavior)

Use this code by adding this in bootstrap/app.php

```
\Jarnix\LaravelAutoEnvironment\Loader::init($app, [
    'envsFolder' => '/config',
    'hostLocalRegexp' => '/vagrantphp7',
    'urlLocalRegexp' => '/l\.webedev\.com/',
    'urlTestingRegexp' => '/test\.webedev.com/',
    'urlProductionRegexp' => '/www\.webedev.com/'
]);

```

Put your different configuration files in the app's "/config" folder, or another folder (specified as the 'envsFolder' parameter) :

- .env.local
- .env.testing
- .env.production

Parameters
----------

[](#parameters)

You can customize these parameters:

- envsFolder: where you put the .env files (local.env, production.env...)
- hostnameLocalRegexp: the regexp for the hostname in local mode (cli)
- urlLocalRegexp: the regexp for the http host in local mode (http)
- urlTestingRegexp: the regexp for the http host in testing mode (http)
- urlProductionRegexp: the regexp for the http host in prod mode (http)

You can force the environment everywhere
----------------------------------------

[](#you-can-force-the-environment-everywhere)

You can also force the environment you want by creating a file called "env" at the root of the app, containing the environment you want to load.

This code will then load the "env" file that you want in the "envsFolder" folder. For example: if the file's content is "local" =&gt; the file : /config/.env.local will be loaded

You can still force the environment in artisan
----------------------------------------------

[](#you-can-still-force-the-environment-in-artisan)

If you haven't created a env file, you can still obviously force the environment by using:

```
php artisan --env=testing

```

Or use a .env file
------------------

[](#or-use-a-env-file)

And you can use a .env file as usual, this will then bypass this code.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 88.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

7

Last Release

2981d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3f96311782e7bedc7f4ca44c8e30e14fd78e8dec1db31a51622e29fef4518472?d=identicon)[jarnix](/maintainers/jarnix)

---

Top Contributors

[![jarnix](https://avatars.githubusercontent.com/u/1163073?v=4)](https://github.com/jarnix "jarnix (24 commits)")[![adsdeploy](https://avatars.githubusercontent.com/u/64137051?v=4)](https://github.com/adsdeploy "adsdeploy (3 commits)")

---

Tags

environmentlaravel5sexy

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/jarnix-laravel-auto-environment/health.svg)

```
[![Health](https://phpackages.com/badges/jarnix-laravel-auto-environment/health.svg)](https://phpackages.com/packages/jarnix-laravel-auto-environment)
```

###  Alternatives

[wireui/wireui

TallStack components

1.8k1.3M16](/packages/wireui-wireui)[livewire/volt

An elegantly crafted functional API for Laravel Livewire.

4195.3M84](/packages/livewire-volt)[ramonrietdijk/livewire-tables

Dynamic tables for models with Laravel Livewire

21147.4k](/packages/ramonrietdijk-livewire-tables)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
