reinfi/laminas-env-mapper

Map $_ENV to objects using EnvMapper

v1.1.0 2024-02-22 07:19 UTC

This package is auto-updated.

Last update: 2024-04-22 21:22:13 UTC


README

Using EnvMapper to map $_ENV to objects.

  1. Installation
  2. Environment Object Mapping
  3. FAQ

Installation

  1. 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.