kimtooflex / envswitch
Code once, host anywhere, run everywhere
Installs: 16
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/kimtooflex/envswitch
Requires
- php: >=5.4
Requires (Dev)
- phpunit/phpunit: 5.2.*
This package is not auto-updated.
Last update: 2025-12-22 05:18:30 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"); } );