2017 © Pedro Peláez
 

library silex-environment-serviceprovider

image

frostiede/silex-environment-serviceprovider

  • Sunday, October 16, 2016
  • by frostieDE
  • Repository
  • 1 Watchers
  • 0 Stars
  • 704 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 3 % Grown

The README.md

Silex Environment ServiceProvider

Build Status Code Climate, (*1)

ServiceProvider for Silex which empowers use of environments like prod, dev etc. Environments can be changed using an environment variable., (*2)

Installation

$ composer require frostiede/silex-environment-serviceprovider

Afterwards, register the ServiceProvider:, (*3)

$app->register(new EnvironmentServiceProvider());

Usage

You can now use $app['env'] to get the current environment. Also, you can use $app['cli'] to detect whether the current application is invoked by command line (in this case, it is set to true, false otherwise)., (*4)

CLI

When invoking any command from CLI (e.g. using the Command extension), you should prepend the target environment:, (*5)

$ APP_ENV=dev php bin/console your:command

Webserver

Create two separate PHP endpoint files (index.php and dev.php) and set your environment variable according to the file. For example, dev.php should contain putenv("APP_ENV=dev") to make all requests from dev.php run in dev-environment., (*6)

Note: Ensure dev.php is not accessible in production!, (*7)

Configuration

You can set the environment variable which this extension evaluates. As default, APP_ENV is used but you change it to whatever you want using the constructor:, (*8)

$app->register(new EnvironmentServiceProvider('ENV'));

Contribution

Any help is welcomed. Feel free to create issues and merge requests :-), (*9)

License

MIT License, (*10)

The Versions

16/10 2016

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marcel Marnitz

silex pimple

16/10 2016

v1.0.0

1.0.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marcel Marnitz

silex pimple