PHPackages                             rstgroup/zf-consul-service-discovery-module - 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. rstgroup/zf-consul-service-discovery-module

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

rstgroup/zf-consul-service-discovery-module
===========================================

Module for Zend Framework that allows to register the application in Consul's Service Discovery.

012PHP

Since Jul 25Pushed 8y ago13 watchersCompare

[ Source](https://github.com/rstgroup/zf-consul-service-discovery-module)[ Packagist](https://packagist.org/packages/rstgroup/zf-consul-service-discovery-module)[ RSS](/packages/rstgroup-zf-consul-service-discovery-module/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

ZF Consul Service Discovery Module
==================================

[](#zf-consul-service-discovery-module)

This module provides logic that allows the application to register itself in Consul's Service Discovery.

[![Build Status](https://camo.githubusercontent.com/81eb8e395b3e1392317d63ea741dbb1a34536d5d9109d117bde71e1848fde5df/68747470733a2f2f7472617669732d63692e6f72672f72737467726f75702f7a662d636f6e73756c2d736572766963652d646973636f766572792d6d6f64756c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/rstgroup/zf-consul-service-discovery-module)

Requirements
------------

[](#requirements)

1. PHP: 5.6 or 7.X
2. ZF3-compatible application
3. reachable Consul Agent API

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

[](#installation)

Require module with Composer:

```
composer require rstgroup/zf-consul-service-discovery-module
```

The next step is adding module to ZF system configuration (`config/application.config.php`):

```
return [
    'modules' => [
        (...),
        'RstGroup\ZfConsulServiceDiscoveryModule',
    ],
    (...)
]
```

.. and (optionally, but we strongly suggest it) - [install `rstgroup/zf-local-config-module`](https://packagist.org/packages/rstgroup/zf-local-config-module).

Configuration
-------------

[](#configuration)

The module requires the presence of:

- Consul API URL
- service name
- service ID *(if service name is not unique across the same Consul Agent instance)*

Example configuration:

```
return [
    'rst_group'       => [
        'service_discovery' => [
            'service_name' => 'my-service',
            'service_id'   => 'my-service-1',
            'consul'       => [
                'url' => 'http://consul-instance.loc:8500',
                'check' => [
                    'url' => 'http://my-service/check-endpoint',
                    'name' => 'check-endpoint',
                    'interval' => '30s',
                ],
                'tags' => [ 'service', 'httpd', 'php' ],
            ],
        ],
    ],
];
```

Minimal configuration:

```
return [
    'rst_group'       => [
        'service_discovery' => [
            'service_name' => 'my-service',
            'consul'       => [
                'url' => 'http://consul-instance.loc:8500',
            ],
        ],
    ],
];
```

> We suggest using `rstgroup/zf-external-config-module` to pass `rst_group.service_discovery.consul.url` key during the provisioning stage - as infrastructure configuration should not be stored in application's repository.

> If your service is about to be ran in many instances - then also its name should be passed during the provisioning state.

Usage
-----

[](#usage)

Module provides simple commands to register/deregister service in Consul Agent. Both of them are described when you run `php public/index.php` with no arguments.

### Registering service in Consul Agent

[](#registering-service-in-consul-agent)

In POST-install script:

1. *(optional)* Provide required configuration for Consul Agent:

    ```
    php public/index.php local-config set rst_group.service_discovery.consul.url http://consul-instance.loc:8500
    ```

    Let's assume that service name and ID is already in configuration.

    > Remeber that this command requires you to have `rstgroup/zf-external-config-module` installed as well.
2. Register service:

    ```
    php public/index.php service-discovery consul register
    ```

### Deregistering service

[](#deregistering-service)

IN POST-uninstall stage:

```
```bash
php public/index.php service-discovery consul deregister
```

```

### Running commands with parameters

[](#running-commands-with-parameters)

`service-discovery consul register` command has defined set of optional attributes that allows you to override settings stored in your app's configuration. You can list the full usage information by simply typing:

`php public/index.php`

Here's the part that describes the `zf-consul-service-discovery-module`'s commands:

```
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    RstGroup\ZfConsulServiceDiscoveryMod
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    ZF Service Discovery - Consul
      index.php service-discovery consul register [--id=] [--name=] [--tags=] [--check] [--check-url=] [--check-name=] [--check-interval=]    Register service in Consul Agent's Service Discovery.

      --id=               Override ID of service.
      --name=             Override name of service.
      --tags=             Override list of tags. Write tags as comma-separated list with no whitespaces.
      --check             If flag is set, the check is expected to be defined.
      --check-url         Override service's check URL
      --check-name        Override service's check name
      --check-interval    Override service's check interval

      index.php service-discovery consul deregister [--id=]    Deregister service in Consul Agent' Service Discovery.

      --id=    Override ID of service.

```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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/6ffa5d2fe34b04844f854a4fa7ce073c69a500fe6352d69461756abf1b23599d?d=identicon)[rstgroup](/maintainers/rstgroup)

---

Top Contributors

[![artospaj](https://avatars.githubusercontent.com/u/11021356?v=4)](https://github.com/artospaj "artospaj (1 commits)")[![snapshotpl](https://avatars.githubusercontent.com/u/312655?v=4)](https://github.com/snapshotpl "snapshotpl (1 commits)")

### Embed Badge

![Health badge](/badges/rstgroup-zf-consul-service-discovery-module/health.svg)

```
[![Health](https://phpackages.com/badges/rstgroup-zf-consul-service-discovery-module/health.svg)](https://phpackages.com/packages/rstgroup-zf-consul-service-discovery-module)
```

###  Alternatives

[devfactory/minify

A package for minifying styles and javascript for laravel 5

87363.5k14](/packages/devfactory-minify)[bluemmb/faker-picsum-photos-provider

picsum.photos provider for Faker

31225.7k1](/packages/bluemmb-faker-picsum-photos-provider)[vufind-org/vufindharvest

VuFind Harvest Tools

23285.4k2](/packages/vufind-org-vufindharvest)[backpack/activity-log

Activity Log for Backpack

3487.5k1](/packages/backpack-activity-log)[sulu/automation-bundle

The Sulu Bundle which provides automation functionality

18289.1k8](/packages/sulu-automation-bundle)[husam-tariq/filament-timepicker

Filament 3.x Time Picker

3361.2k2](/packages/husam-tariq-filament-timepicker)

PHPackages © 2026

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