graviton / vcap-config-loader
Load services config from a VCAP_SERVICES json definition.
Installs: 4 690
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 20
Forks: 0
Open Issues: 0
Requires
- flow/jsonpath: 0.2.*
Requires (Dev)
This package is auto-updated.
Last update: 2022-01-28 08:51:02 UTC
README
Parses and loads the contents of a vcap services variable as provided by cloundfoundry clouds.
This is just a very small wrapper around flow/jsonpath. It is intended to make it easy to configure services based on things cloudfoundry injects through the VCAP_SERVICES env variable.
This package adheres to SemVer versioning.
It uses a github version of git-flow in which new features and bugfixes must be merged to develop using a github pull request. It uses the standard git-flow naming conventions with the addition of a 'v' prefix to version tags.
Install
composer require graviton/vcap-config-loader '*'
Usage
<?php require 'vendor/autoload.php'; use Graviton\Vcap\Loader; // create loader and inject data $loader = new Loader; $loader->setInput($_ENV['VCAP_SERVICES']); // what to extract $type = 'mariadb-'; $name = 'my-awesome-service'; // data extraction $dbConfig = array( 'db' => $loader->getDb($type, $name), 'host' => $loader->getHost($type, $name), 'port' => $loader->getPort($type, $name), 'database' => $loader->getDatabase($type, $name), 'username' => $loader->getUsername($type, $name), 'password' => $loader->getPassword($type, $name), );