graviton/vcap-config-loader

This package is abandoned and no longer maintained. No replacement package was suggested.

Load services config from a VCAP_SERVICES json definition.

v0.2.0 2015-02-22 04:52 UTC

This package is auto-updated.

Last update: 2022-01-28 08:51:02 UTC


README

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version Total Downloads Latest Unstable Version License

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),
);