PHPackages                             so-php/service-registry - 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. so-php/service-registry

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

so-php/service-registry
=======================

Service Registry Implementation

0.0.2-alpha(12y ago)191PHP

Since Jun 15Pushed 12y ago1 watchersCompare

[ Source](https://github.com/so-php/service-registry)[ Packagist](https://packagist.org/packages/so-php/service-registry)[ RSS](/packages/so-php-service-registry/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (5)Versions (3)Used By (1)

service-registry
================

[](#service-registry)

Service Registry Library built on top of php-amqplib and Zookeeper php extension.

Service Registry Pattern
========================

[](#service-registry-pattern)

To explain the service registry pattern lets take a look at how a programmer might utilize a service in some typical scenarios.

Without Service Registry Pattern
--------------------------------

[](#without-service-registry-pattern)

Using a service that is available locally

```
$service = new Service();
$service->method();

```

Using a service that is available remotely

```
$rpc = new XmlRpc('path/to/service/descriptor.wsdl');
$rpc->call('method');

```

Using a service that is available remotely and *may* be available locally

```
if(class_exists('Service')){
    $service = new Service();
    $service->method();
} else {
    $rpc = new XmlRpc('path/to/service/descriptor.wsdl');
    $rpc->call('method');
}

```

Using a service that is available from multiple remote services using a decision strategy like load-balancing, or A\\B testing to pick a remote provider

```
??? what?

```

Unfortunately that kind of behaviour can't even be pseudo-coded in a simple enough manner to provide a sample. And there's not really a common methodology to implementing such features--you'd be on your own if you wanted to add such behavior to your app.

With Service Registry Pattern
-----------------------------

[](#with-service-registry-pattern)

Lets see how a service registry pattern simplifies these scenarios.

Using a service that is available locally

```
$service = ServiceRegistry::getInstance('Service');
$service->method();

```

Using a service that is available remotely

```
$service = ServiceRegistry::getInstance('Service');
$service->method();

```

Using a service that is available remotely and *may* be available locally

```
$service = ServiceRegistry::getInstance('Service');
$service->method();

```

Using a service that is available from multiple remote services using a decision strategy like load-balancing, or A\\B testing to pick a remote provider

```
ServiceRegistry::setStrategy(new RoundRobin());
// or:  ServiceRegistry::setStrategy(new FirstAvailable());
// or:  ServiceRegistry::setStrategy(new ABTesting());

$service = ServiceRegistry::getInstance('Service');
$service->method();

```

Note how that in all of the scenarios the programmer is faced with exactly the same usage of `Service`.

So, simply put, the service registry pattern is a way to register instances of a service (be it locally, or remotely). Then, you can ask the registry for a reference to one of those instances.

Now, the service registry pattern solves many more problems that haven't been touched on. Things like being able to provide multiple (different) implementations for a service, or providing multiple versions of any given implementation of a service. Lots of cool things that we're not going to go into detail here.

The `Service Registry` library itself provides an implementation of this pattern that orchestrates the mechanics of registering, un-registering and providing service instances whether they be available locally or remotely. If the service instance chosen happens to be remotely available, it hides that complexity away from you. Invisibly it provides you with a proxy that perfectly mirrors the service interface so that you can treat it like a regular Service instance.

Theory of Operation
===================

[](#theory-of-operation)

As it's name suggests, one of the necessities of the pattern is keeping track of services (that have been potentially instantiated in numerable different processes and even servers. On top of maintaining a list of those services, potentially an Remote Procedure Calls (RPC) may need to be orchestrated between an instance reference proxy and the actual instance on a remote server.

Service registration is implemented with Zookeeper, registrations for each instance are stored under ephemeral nodes.

RPC is provided on top of Active MQ Protocol (AMQP) via [php-amqplib](https://github.com/videlalvaro/php-amqplib) (specifically flavored for [RabbitMQ](http://www.rabbitmq.com/)).

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

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.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

4400d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c2445eabf60869a0410b641fbec7b87fea798e5d12e6e31120223cbc230a97ec?d=identicon)[jeremygiberson](/maintainers/jeremygiberson)

---

Top Contributors

[![jeremygiberson](https://avatars.githubusercontent.com/u/487411?v=4)](https://github.com/jeremygiberson "jeremygiberson (2 commits)")

### Embed Badge

![Health badge](/badges/so-php-service-registry/health.svg)

```
[![Health](https://phpackages.com/badges/so-php-service-registry/health.svg)](https://phpackages.com/packages/so-php-service-registry)
```

###  Alternatives

[ec-europa/toolkit

Toolkit packaged for Drupal projects based on Robo.

40252.8k34](/packages/ec-europa-toolkit)

PHPackages © 2026

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