2017 © Pedro Peláez
 

library laravel-auto-environment

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

image

jarnix/laravel-auto-environment

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

  • Wednesday, March 14, 2018
  • by jarnix
  • Repository
  • 1 Watchers
  • 1 Stars
  • 51 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 28 % Grown

The README.md

For Laravel 5+

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

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), (*1)

Use this code by adding this in bootstrap/app.php, (*2)

\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, (*3)

Parameters

You can customize these parameters:, (*4)

  • 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 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., (*5)

This code will then load the "env" file that you want in the "envsFolder" folder. For example: if the file's content is "local" => the file : /config/.env.local will be loaded, (*6)

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:, (*7)

php artisan --env=testing

Or use a .env file

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

The Versions

14/03 2018

dev-master

9999999-dev

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Julien Ricard

14/03 2018

1.0.6

1.0.6.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Julien Ricard

28/02 2018

1.0.5

1.0.5.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Julien Ricard

28/02 2018

1.0.4

1.0.4.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Julien Ricard

28/02 2018

v1.0.3

1.0.3.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Julien Ricard

28/02 2018

v1.0.1

1.0.1.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Julien Ricard

28/02 2018

v1.0.2

1.0.2.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Julien Ricard

27/02 2018

1.0

1.0.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Julien Ricard