PHPackages                             sven/env-providers - 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. sven/env-providers

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

sven/env-providers
==================

Load Laravel service providers based on your application's environment.

v4.2.0(1y ago)769.7k8MITPHPPHP ^8.1CI failing

Since May 7Pushed 2mo ago5 watchersCompare

[ Source](https://github.com/svenluijten/env-providers)[ Packagist](https://packagist.org/packages/sven/env-providers)[ RSS](/packages/sven-env-providers/feed)WikiDiscussions 4.x Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (21)Used By (0)

[![env-providers](https://cloud.githubusercontent.com/assets/11269635/15094471/5abfd4ec-14a5-11e6-8969-63bc9bcfd6b6.jpg)](https://cloud.githubusercontent.com/assets/11269635/15094471/5abfd4ec-14a5-11e6-8969-63bc9bcfd6b6.jpg)

Laravel EnvProviders
====================

[](#laravel-envproviders)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ea40556a93b40196385953817256c84be36fc332e0f7e768375c560c34000623/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7376656e2f656e762d70726f7669646572732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sven/env-providers)[![Total Downloads](https://camo.githubusercontent.com/b5355231e36c158553637bb80279a8d8eeb7fd0c4111a3cd49bb2628ea6bb694/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7376656e2f656e762d70726f7669646572732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sven/env-providers)[![Software License](https://camo.githubusercontent.com/6c711032aff1ca0eb6b211aa6cb3649ce7fd64a7714e1181d4bb457f9680e7cf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/e0c65181913d99cb2e7d3e7912c1ca226202a26f6e3565024a1d1b5dcb733e0a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7376656e6c75696a74656e2f656e762d70726f7669646572732f74657374732e796d6c3f7374796c653d666c61742d737175617265)](https://github.com/svenluijten/env-providers/actions/workflows/tests.yml)[![StyleCI](https://camo.githubusercontent.com/ef5a188a0d0708d8ddb077f2a83577ec742bb51715445ac8e56fef4ea88117a6/68747470733a2f2f7374796c6563692e696f2f7265706f732f35383237373735382f736869656c64)](https://styleci.io/repos/58277758)

A more finetuned way of managing your service providers in Laravel. This package allows you to configure the environment certain service providers and aliases are loaded in.

Installation
------------

[](#installation)

Via [composer](http://getcomposer.org):

```
$ composer require sven/env-providers
```

Or add the package to your dependencies in `composer.json` and run `composer update` to download the package:

```
{
    "require": {
        "sven/env-providers": "^4.0"
    }
}
```

Next, add the `ServiceProvider` to your `providers` array in `config/app.php`:

```
// config/app.php
'providers' => [
    ...
    Sven\EnvProviders\ServiceProvider::class,
];
```

Usage
-----

[](#usage)

You must publish this package's configuration file for it to work properly. To do so, run the following command:

```
$ php artisan vendor:publish --provider="Sven\EnvProviders\ServiceProvider"
```

After that, you should see the file `config/providers.php`. In the created configuration file you can see 2 pre-defined provider groups that will help you set up what providers and aliases should be loaded when the application is in any of the configured environments.

### Environments

[](#environments)

In the `environments` array you can define what are known as "environment aliases". For example, if you use more than one name for `local` development (eg. `dev`, `development`, and `local`), you can alias all of these to *one* name to use in this package's configuration.

**Note**: You can set your application's environment in either `config/app.php`under `env` or via your `.env` file. If you want to manage your `.env` file via `php artisan`, you can check out [`sven/flex-env`](https://git.io/flex).

### Groups

[](#groups)

The `groups` key in the configration is used to load in service providers and aliases (also know as facades) in one of the previously defined environments. You can use `*` as a wildcard here to *always* load that group, regardless of the application's environment.

#### Providers

[](#providers)

The `providers` array is where you can put the providers you want to have loaded in the defined environment. This should be pretty straight forward as it is similar to how you would register service providers in `config/app.php`.

#### Aliases

[](#aliases)

In the `aliases` array you may define all your aliases (facades). As with the providers, this is the same as how you would register aliases in the default `config/app.php` configuration file.

### Example

[](#example)

```
return [
    'environments' => [
        'dev' => ['local', 'development', 'dev'],
        'prod' => ['production'],
    ],

    'groups' => [
        'dev' => [
            'providers' => [
                Sven\ArtisanView\ArtisanViewServiceProvider::class,
                Barryvdh\Debugbar\ServiceProvider::class,
            ],
            'aliases' => [
                'Debugbar' => Barryvdh\Debugbar\Facade::class,
            ],
        ],
        'prod' => [
            'providers' => [ /* ... */ ],
            'aliases' => [ /* ... */ ],
        ],
        '*' => [
            'providers' => [ /* ... */ ],
            'aliases' => [ /* ... */ ],
        ],
    ],

],
```

Notice how we're only loading the Debugbar ServiceProvider and facade when our application's environment is either `local`, `development`, or `dev`. This means we can't use the `Debugbar` facade in our project when the environment doesn't match any of those.

Contributing
------------

[](#contributing)

All contributions (pull requests, issues and feature requests) are welcome. Make sure to read through the [CONTRIBUTING.md](CONTRIBUTING.md) first, though. See the [contributors page](../../graphs/contributors) for all contributors.

License
-------

[](#license)

`sven/env-providers` is licensed under the MIT License (MIT). Please see the [license file](LICENSE.md) for more information.

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance66

Regular maintenance activity

Popularity34

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 55.4% 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 ~200 days

Recently: every ~378 days

Total

19

Last Release

50d ago

Major Versions

1.0.2 → 2.0.02016-05-07

2.0.1 → 3.0.02016-05-12

v3.2.0 → v4.0.02022-02-05

PHP version history (4 changes)1.0.0PHP ^5.5.9 || ^7.0

v3.1.0PHP &gt;=7.1.3

3.x-devPHP ^8.0

v4.1.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/6682e025b83b7a93b4d43c5c9b0b2245d790d72352758c47b81ba14858f45a8a?d=identicon)[svenluijten](/maintainers/svenluijten)

---

Top Contributors

[![svenluijten](https://avatars.githubusercontent.com/u/11269635?v=4)](https://github.com/svenluijten "svenluijten (51 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (39 commits)")[![gogl92](https://avatars.githubusercontent.com/u/1505641?v=4)](https://github.com/gogl92 "gogl92 (2 commits)")

---

Tags

artisanenvironmentenvironment-variableshacktoberfestlaravelpackageproviderslaravelproviderenvironmentserviceprovider

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sven-env-providers/health.svg)

```
[![Health](https://phpackages.com/badges/sven-env-providers/health.svg)](https://phpackages.com/packages/sven-env-providers)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[msztorc/laravel-env

Laravel env helper commands

7855.4k](/packages/msztorc-laravel-env)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)[harmonic/laravel-envcoder

:description

414.1k](/packages/harmonic-laravel-envcoder)[nedwors/navigator

A Laravel package to ease defining navigation menus

433.1k](/packages/nedwors-navigator)

PHPackages © 2026

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