reinfi / laminas-env-mapper
Map $_ENV to objects using EnvMapper
v1.1.0
2024-02-22 07:19 UTC
Requires
- php: ~8.1.0 || ~8.2.0 || ~8.3.0
- crell/envmapper: ^1.0
- laminas/laminas-servicemanager: ^2.7 | ^3.0
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.0
- symplify/easy-coding-standard: ^11.2
This package is auto-updated.
Last update: 2024-10-22 22:34:39 UTC
README
Using EnvMapper to map $_ENV to objects.
Installation
- Install with Composer:
composer require reinfi/laminas-env-mapper
.
Environment Object Mapping
Just specify the factory for your object, this will then map the object with EnvMapper.
'service_manager' => [ 'factories' => [ YourEnvironmentObject::class => \Reinfi\LaminasEnvMapper\Factory\EnvObjectMapperFactory::class, ], ]
You could use the object in your container by retrieving it.
$container->get(YourEnvironmentObject::class);
Abstract Factory Usage
If you do not want to register all your environment objects to the container you could register an abstract factory.
'service_manager' => [ 'abstract_factories' => [ \Reinfi\LaminasEnvMapper\AbstractFactory\\Reinfi\LaminasEnvMapper\AbstractFactory\AbstractEnvObjectMapperFactory::class, ], ]
Your objects must extend the EnvObjectInterface
.
FAQ
Feel free to ask any questions or open own pull requests.