PHPackages                             texthtml/docker-links - 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. texthtml/docker-links

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

texthtml/docker-links
=====================

A helper for parsing Docker link environment variables.

v1.5.0(9y ago)121.6k↑464.3%3[1 issues](https://github.com/texthtml/docker-links/issues)[2 PRs](https://github.com/texthtml/docker-links/pulls)2AGPL-3.0PHP

Since Jun 2Pushed 1y ago1 watchersCompare

[ Source](https://github.com/texthtml/docker-links)[ Packagist](https://packagist.org/packages/texthtml/docker-links)[ RSS](/packages/texthtml-docker-links/feed)WikiDiscussions master Synced yesterday

READMEChangelog (6)Dependencies (2)Versions (11)Used By (2)

Docker Links Environment Parser
===============================

[](#docker-links-environment-parser)

[![Build Status](https://camo.githubusercontent.com/ba28ef37805fe5deb8f0d5dd9adfb3471734e76f0cd86ba1d1e111dcac1490ed/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7465787468746d6c2f646f636b65722d6c696e6b732e737667)](https://travis-ci.org/texthtml/docker-links)[![Code Status](https://camo.githubusercontent.com/c991f1748c25841531ec6e74587331227259d7e34c4014b6d3401f262d014699/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7465787468746d6c2f646f636b65722d6c696e6b732e737667)](https://scrutinizer-ci.com/g/texthtml/docker-links/build-status/master)[![Latest Version](https://camo.githubusercontent.com/b744b8ad51715ef260277e2854729ee32f19ab331dfa65c69b12bd54cf035afc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7465787468746d6c2f646f636b65722d6c696e6b732e737667)](https://packagist.org/packages/texthtml/docker-links)[![License](https://camo.githubusercontent.com/3ef88b1f831969c1188a78a4dbfc7aa4c3d2b6b34ea99ddfc9af6e1ac0768800/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7465787468746d6c2f646f636b65722d6c696e6b732e737667)](https://packagist.org/packages/texthtml/docker-links)

[Docker](http://www.docker.io/) has a feature where you can [link containers together by name](http://docs.docker.io/en/latest/use/working_with_links_names/). For example, you start a redis-server in a docker container and expose the default redis port 6379:

```
$ docker run -p 6379 -d -name redis vagrant/redis-server

```

You then start another containiner running a php-fpm web service that needs to access this redis server:

```
$ docker run --link redis:db -d php:fpm

```

Docker will internally hook up these the two containers and pass host and port information to the php-fpm web service via environment variables:

```
DB_NAME=/romantic_lumiere/db
DB_PORT=tcp://172.17.0.5:6379
DB_PORT_6379_TCP=tcp://172.17.0.5:6379
DB_PORT_6379_TCP_ADDR=172.17.0.5
DB_PORT_6379_TCP_PORT=6379
DB_PORT_6379_TCP_PROTO=tcp

```

This library provides a helper `parseLinks` that will parse these environment variables into easily navigable PHP objects.

### Install

[](#install)

Install `docker-links` via [composer](https://getcomposer.org/)

```
$ composer require texthtml/docker-links

```

### Example Usage

[](#example-usage)

Consider a container that accesses three external services on two other containers. The first container exposes redis on port 6379 and postgres on 6500. The second container exposes redis on port 6379.

```
DB_NAME=/romantic_lumiere/db
DB_PORT=tcp://172.17.0.5:6379
DB_PORT_6379_TCP=tcp://172.17.0.5:6379
DB_PORT_6379_TCP_ADDR=172.17.0.5
DB_PORT_6379_TCP_PORT=6379
DB_PORT_6379_TCP_PROTO=tcp
DB_PORT_6500_TCP=tcp://172.17.0.5:6500
DB_PORT_6500_TCP_ADDR=172.17.0.5
DB_PORT_6500_TCP_PORT=6500
DB_PORT_6500_TCP_PROTO=tcp
DB_REDIS_NAME=/romantic_lumiere/db_redis
DB_REDIS_PORT=tcp://172.17.0.2:6379
DB_REDIS_PORT_6379_TCP=tcp://172.17.0.2:6379
DB_REDIS_PORT_6379_TCP_ADDR=172.17.0.2
DB_REDIS_PORT_6379_TCP_PORT=6379
DB_REDIS_PORT_6379_TCP_PROTO=tcp

```

Parse with `docker-links`:

```
$links = \TH\Docker\Links::buildFrom($_ENV);

// $links can be used as an array
echo count($links), PHP_EOL; // 2
foreach ($links as $name => $link) {
    echo $name, PHP_EOL; // /romantic_lumiere/db, /romantic_lumiere/db
}

// each link is an instanceof [Link](test)
$link = $links['/romantic_lumiere/db'];

echo $link->mainPort()->address(), PHP_EOL; // 172.17.0.5
echo $link->mainPort()->protocol(), PHP_EOL; // TCP
echo $link->mainPort()->number(), PHP_EOL; // 6379

echo $link->env()['USERNAME'], PHP_EOL; // username
echo $link->env('PASSWORD'), PHP_EOL; // password
echo $link->env('SOMETHING_ELSE'), PHP_EOL; // NULL
echo $link->env('SOMETHING', 'default value'), PHP_EOL; // default value
```

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance8

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 80% 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.

###  Release Activity

Cadence

Every ~84 days

Recently: every ~122 days

Total

7

Last Release

3545d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3943b5c35797d1ede53aaed3d6812e4cf5b2dba7619a00dc7a381480a7b3d330?d=identicon)[mathroc](/maintainers/mathroc)

---

Top Contributors

[![mathroc](https://avatars.githubusercontent.com/u/291531?v=4)](https://github.com/mathroc "mathroc (8 commits)")[![jfilliard](https://avatars.githubusercontent.com/u/4246317?v=4)](https://github.com/jfilliard "jfilliard (1 commits)")[![text-html-renovate[bot]](https://avatars.githubusercontent.com/u/6465918?v=4)](https://github.com/text-html-renovate[bot] "text-html-renovate[bot] (1 commits)")

###  Code Quality

TestsBehat

### Embed Badge

![Health badge](/badges/texthtml-docker-links/health.svg)

```
[![Health](https://phpackages.com/badges/texthtml-docker-links/health.svg)](https://phpackages.com/packages/texthtml-docker-links)
```

###  Alternatives

[cagartner/correios-consulta

Package para pesquisa de serviços de busca por cep, calculo de frete e etc, diretamente nos serviços dos Correios.

159302.6k](/packages/cagartner-correios-consulta)[davmixcool/php-sentiment-analyzer

PHP Sentiment Analyzer is a lexicon and rule-based sentiment analysis tool that is used to understand sentiments in a sentence using VADER (Valence Aware Dictionary and sentiment Reasoner).

136173.7k1](/packages/davmixcool-php-sentiment-analyzer)[prestashop/decimal

Object-oriented wrapper/shim for BC Math PHP extension. Allows for arbitrary-precision math operations.

178.9M9](/packages/prestashop-decimal)

PHPackages © 2026

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