PHPackages                             mihui/php-vcap - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mihui/php-vcap

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mihui/php-vcap
==============

Library of accessing IBM Cloud VCAP\_SERVICES environment variables.

050PHP

Since Jul 27Pushed 7y ago1 watchersCompare

[ Source](https://github.com/mihui/php-vcap)[ Packagist](https://packagist.org/packages/mihui/php-vcap)[ RSS](/packages/mihui-php-vcap/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

php-vcap
========

[](#php-vcap)

[![Language: PHP](https://camo.githubusercontent.com/02e8771b801f79c341fe2f969c2817573d8a77816910e10edd3141066f007bb9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d352e362b2d6f72616e67652e7376673f7374796c653d666c6174)](http://php.net/)[![Build Status](https://camo.githubusercontent.com/73f60b0f5db9075849b772ff2532be3610855bc93b318e20abc635b6e839ad8d/68747470733a2f2f7472617669732d63692e6f72672f6d696875692f7068702d766361702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mihui/php-vcap)[![codecov](https://camo.githubusercontent.com/8522c7f2cb8a1a36c94cb824a687bc12de86d6b3701424527a59a7d3b1a4ad77/68747470733a2f2f636f6465636f762e696f2f67682f6d696875692f7068702d766361702f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/mihui/php-vcap)

Library of accessing IBM Cloud VCAP\_SERVICES environment variables.

Installation
------------

[](#installation)

Installing [Composer](http://getcomposer.org) will be easier to manage dependencies for your application.

Run the Composer command to install the latest version of the Watson PHP SDK:

```
composer require mihui/php-vcap:dev-master
```

If the php-vcap is downloaded from GitHub already, run the update command:

```
composer update
```

Include `autoload.php` in your application:

```
require 'vendor/autoload.php';
```

Namespaces
----------

[](#namespaces)

For common use, one of the namespaces of `WatsonCredential` or `SimpleTokenProvider` can be optional, depends on how to invoke the Watson services, and you can reference the classes like so:

```
use ENV\VCAP;
```

How to use
----------

[](#how-to-use)

Refer to the `env.json file` in this repository, it is the example of the VCAP\_SERVICES environment data from the IBM Cloud/Cloudfoundry, and it will be the env file for you to do the local development work on your machine, and you SHOULD NOT place the `env.json` file on the cloud. To do that, please add the `env.json` to your `.gitignore`. If you must have this file for other purpuses, please let me know I will add an option to change the file name.

```
{
    "tone_analyzer": [
        {
            "credentials": {
                "url": "https://gateway.watsonplatform.net/tone-analyzer/api",
                "username": "your_username_tone_analyzer",
                "password": "your_password_tone_analyzer"
            },
            "syslog_drain_url": null,
            "volume_mounts": [],
            "label": "tone_analyzer",
            "provider": null,
            "plan": "standard",
            "name": "Tone Analyzer",
            "tags": [
                "ibm_created",
                "ibm_dedicated_public",
                "lite",
                "watson"
            ]
        }
    ],
    "cloudantNoSQLDB": [
        {
            "credentials": {
                "username": "your_username",
                "password": "your_password",
                "host": "your_username-bluemix.cloudant.com",
                "port": 443,
                "url": "https://your_username-bluemix:your_password@cyour_username-bluemix.cloudant.com"
            },
            "syslog_drain_url": null,
            "volume_mounts": [],
            "label": "cloudantNoSQLDB",
            "provider": null,
            "plan": "Shared",
            "name": "Cloudant NoSQL DB",
            "tags": [
                "data_management",
                "ibm_created",
                "lite",
                "ibm_dedicated_public"
            ]
        }
    ],
    "conversation": [
        {
            "credentials": {
                "url": "https://gateway.watsonplatform.net/conversation/api",
                "username": "your_username",
                "password": "your_password"
            },
            "syslog_drain_url": null,
            "volume_mounts": [],
            "label": "conversation",
            "provider": null,
            "plan": "free",
            "name": "Conversation",
            "tags": [
                "eu_access",
                "ibm_created",
                "ibm_dedicated_public",
                "lite",
                "watson"
            ]
        }
    ]
}
```

In order to get the credentials of `tone_analyzer`, use the sample code below, the parameter `tone_analyzer` must be the key in your JSON:

```
$credentails = VCAP::getInstance()->getServiceCredential('tone_analyzer');

echo $credentails['username'];
echo $credentails['password'];
echo $credentails['url'];
```

License
-------

[](#license)

Copyright 2018 under [the Apache 2.0 license](LICENSE).

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/732dfd3f7d43ae393e8d34ebf8a8bee749b95e3245ca49ce239140e866a12c73?d=identicon)[mihui](/maintainers/mihui)

---

Top Contributors

[![mihui](https://avatars.githubusercontent.com/u/1511528?v=4)](https://github.com/mihui "mihui (13 commits)")

---

Tags

ibm-cloudphpvcapvcap-services

### Embed Badge

![Health badge](/badges/mihui-php-vcap/health.svg)

```
[![Health](https://phpackages.com/badges/mihui-php-vcap/health.svg)](https://phpackages.com/packages/mihui-php-vcap)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
