kimtooflex / envswitch
Code once, host anywhere, run everywhere
dev-master
2018-09-03 07:15 UTC
Requires
- php: >=5.4
Requires (Dev)
- phpunit/phpunit: 5.2.*
This package is not auto-updated.
Last update: 2025-08-18 03:34:03 UTC
README
Code once, host anywhere, run everywhere
envswitch.php is a fast & flexible environment switching library for PHP 5.X+
- Define multiple production or development servers
- Callback compatibility
- No Server limits
Getting started
- PHP 5.x.x is required
- Install envswitch using Composer (recommended)
Composer Installation
- Get Composer
- Require Klein with
php composer.phar require kimtooflex/envswitch
- Add the following to your application's main PHP file:
use \envswitch\EnvSwitch;
Example
Hello World - Obligatory hello world example (one server)
<?php use \envswitch\EnvSwitch; EnvSwitch::setEnv("127.0.0.2", function() { die("Hello world, this is development environment"); }, function() { die("Hello world, this is production environment"); } );
Example 1 - Respond to many servers
<?php use \envswitch\EnvSwitch; EnvSwitch::setEnv("127.0.0.2,localhost", function() { die("Hello world, this is development environment"); }, function() { die("Hello world, this is production environment"); } );