jenky / laravel-envloader by Milano

Laravel 5 environment loader
855
0
2
Package Data
Maintainer Username: Milano
Maintainer Contact: jenky.w0w@gmail.com (Linh Tran)
Package Create Date: 2015-04-01
Package Last Update: 2017-09-15
Language: PHP
License: MIT
Last Refreshed: 2024-11-19 03:01:18
Package Statistics
Total Downloads: 855
Monthly Downloads: 10
Daily Downloads: 0
Total Stars: 0
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

Laravel 5 environment loader

Latest Stable Version Total Downloads License

Load configs, providers, aliases based on the APP_ENV name in .env.

Installation

Require this package with composer:

composer require jenky/laravel-envloader ~1.0

or add this to composer.json

"jenky/laravel-envloader": "~1.0"

After updating composer, add the ServiceProvider to the providers array in config/app.php. Make sure the EnvLoaderServiceProvider is loaded before other app service providers.

'Jenky\LaravelEnvLoader\EnvLoaderServiceProvider',
// or 
Jenky\LaravelEnvLoader\EnvLoaderServiceProvider::class, // PHP 5.5

/*
 * Application Service Providers...
 */
App\Providers\AppServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
// ... 

Copy the package config to your local config with the publish command:

php artisan vendor:publish

The config files will be published to config/app/env

Usage

Modify the config files in config/app/env to suite your needs

/* configs.php */

return [
	'local' => [
		'app' => [
			'url' => 'http://myapp.local',
		],
	],
	'sandbox' => [
		'app' => [
			'url' => 'http://sandbox.myapp.com',
		],
	],
	'testing' => [
		'session' => [
			'driver' => 'file',
		],
	],
];

Multiple environments may be delimited using a "pipe" character

/* aliases.php */

return [
	'local|staging' => [
		'Debugbar' => 'Barryvdh\Debugbar\Facade',
	],
];