shlinkio / shlink-config
Utils to load, parse and work with configuration on Shlink project
Installs: 25 770
Dependents: 6
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: ^8.1
- cuyz/valinor: ^1.0.0
- laminas/laminas-config: ^3.8
- laminas/laminas-servicemanager: ^3.19
Requires (Dev)
- devster/ubench: ^2.1
- infection/infection: ^0.26.19
- phpstan/phpstan: ^1.8
- phpunit/phpunit: ^10.0
- psr/simple-cache: ^2.0
- roave/security-advisories: dev-master
- shlinkio/php-coding-standard: ~2.3.0
- symfony/var-dumper: ^6.1
README
Utils to load, parse and work with configuration on Shlink project.
Installation
Install this tool using composer.
composer install shlinkio/shlink-config
This library is also a mezzio module which provides its own
ConfigProvider
. Add it to your configuration to get everything automatically set up.
Included utils
-
loadConfigFromGlob
: Function which expects a glob pattern and loads and merges all config files that match it. -
EnvVarLoaderProvider
: A config provider which loads the entries of the loaded config into env vars and always returns empty. Designed to be the first config provider in the pipeline. -
DottedAccessConfigAbstractFactory
: An abstract factory that lets any config param to be fetched as a service by using theconfig.foo.bar
notation. -
ValinorConfigFactory
: A PSR-11 factory that lets you map arbitrary objects from arrays, using cuyz/valinior.In order to use it, you have to register the object to map as a service, and the ValinorConfigFactory with static access using the service that returns the raw array with the data as the static method name:
<?php declare(strict_types=1); return [ MyCoolOptions::class => [ValinorConfigFactory::class, 'config.foo.options'], ];
It is useful to combine this factory with the
DottedAccessConfigAbstractFactory
.The mapping will be done with cache if a
Psr\SimpleCache\CacheInterface
service is found.