amtgard / environment-loader
Environment-agnostic PHP include path selection for composition roots (Registry + Strategy).
v1.0.0
2026-10-01 02:46 UTC
Requires
- php: ^8.1
- amtgard/builder-traits: ^1.0
- jedibc/optional: ^1.0
- psr/log: ^3.0
Requires (Dev)
- monolog/monolog: ^3.7
- phpunit/phpunit: ^11.2
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-01 02:50:26 UTC
README
Environment-agnostic helper for composition roots: register include files per module and environment name, then resolve absolute paths for require.
Depends on amtgard/builder-traits (Builder/Getter) and jedibc/optional for binding selection and optional logging.
Install
composer require amtgard/environment-loader
Usage
use Amtgard\EnvironmentLoader\EnvironmentLoader; $environment = getenv('APP_ENV') ?: 'environment-one'; $envLoad = EnvironmentLoader::builder() ->build() ->defaultPath('environment-one', '/path/to/live/container') ->defaultPath('environment-two', '/path/to/integ/container'); $envLoad->register('oauth') ->withEnvironment('environment-one', 'oauth-providers.php', EnvironmentLoader::DEFAULT) ->withEnvironment('environment-two', 'oauth-providers-integ.php'); (require $envLoad->emit('oauth', $environment))($containerBuilder);
Optional PSR-3 logger: EnvironmentLoader::builder()->logger($logger)->build()->defaultPath(...).
Development
composer install
composer test