Load services config from a VCAP_SERVICES json definition.
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.
composer require graviton/vcap-config-loader '*'
<?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), );