PHPackages                             apu/php-eureka-server - 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. [API Development](/categories/api)
4. /
5. apu/php-eureka-server

ActiveLibrary[API Development](/categories/api)

apu/php-eureka-server
=====================

A PHP client for Spring Cloud Eureka discovery server.

v1.0.0(3y ago)0425MITPHPPHP &gt;=5.4.0

Since Aug 17Pushed 3y agoCompare

[ Source](https://github.com/AGPAYTECH-Programming-Universe/PHP-Eureka-Server)[ Packagist](https://packagist.org/packages/apu/php-eureka-server)[ Docs](http://hamid.work)[ RSS](/packages/apu-php-eureka-server/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

PHP Netflix Eureka Client
=========================

[](#php-netflix-eureka-client)

A PHP client for (Spring Cloud) Netflix Eureka service registration and discovery.

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

[](#installation)

You can install this package using [Composer](https://getcomposer.org/):

`composer require apu/php-eureka-server`

Documentation
-------------

[](#documentation)

### Create Eureka Client

[](#create-eureka-client)

The very first thing you need to do is to create an instance of `EurekaClient` using your own configuration:

```
$client = new EurekaClient([
    'eurekaDefaultUrl' => 'http://localhost:8761/eureka',
    'hostName' => 'service.hamid.work',
    'appName' => 'service',
    'ip' => '127.0.0.1',
    'port' => ['8080', true],
    'homePageUrl' => 'http://localhost:8080',
    'statusPageUrl' => 'http://localhost:8080/info',
    'healthCheckUrl' => 'http://localhost:8080/health'
    'additionalHeaders' = [],
]);
```

List of all available configuration are as follows:

- `eurekaDefaultUrl` (default: `http://localhost:8761`);
- `hostName`
- `appName`
- `ip`
- `status` (default: `UP`)
- `overriddenStatus` (default: `UNKNOWN`)
- `port`
- `securePort` (default: `['443', false]`)
- `countryId ` (default: `1`)
- `dataCenterInfo` (default: `['com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo', 'MyOwn']`)
- `homePageUrl`
- `statusPageUrl`
- `healthCheckUrl`
- `vipAddress`
- `secureVipAddress`
- `heartbeatInterval` (default: `30`)
- `discoveryStrategy` (default: `RandomStrategy`)
- `instanceProvider`
- `additionalHeaders`

You can also change the configuration after creating `EurekaClient` instance, using setter methods:

```
$client->getConfig()->setAppName("my-service");
```

### Operations

[](#operations)

After creating EurekaClient instance, there will be multiple operations to perform:

- **Registration:** register your service instance with Eureka

```
$client->register();
```

- **De-registration:** de-register your service instance from Eureka

```
$client->deRegister();
```

- **Heartbeat:** send heartbeat to Eureka, to show the client is up (one-time heartbeat)

```
$client->heartbeat();
```

You can register your instance and send periodic heartbeat using `start()` method:

```
$client->start();
```

Using this method, first your service gets registered with Eureka using the configuration you have provided. Then, a heartbeat will be sent to the Eureka periodically, based on `heartbeatInterval` configuration value. This interval time can be changed just like any other configuration item:

```
$client->getConfig()->setHeartbeatInterval(60); // 60 seconds
```

It's apparent that this method should be used in CLI.

- **Service Discovery**: fetch an instance of a service from Eureka:

```
$instance = $client->fetchInstance("the-service");
$homePageUrl = $instance->homePageUrl;
```

### Discovery Strategy

[](#discovery-strategy)

When fetching instances of a service from Eureka, you probably get a list of available instances. You can choose one of them based on your desired strategy of load balancing. For example, a Round-robin or a Random strategy might be your choice.

Currently, this library only supports `RandomStrategy`, however, you can create your custom strategy by implementing `getInstance()` method of `DiscoveryStrategy` interface:

```
class RoundRobinStrategy implements DiscoveryStrategy {

    public function getInstance($instances) {
        // return an instance
    }

}
```

Then, all you have to do is to introduce your custom strategy to `EurekaClient` instance:

```
$client->getConfig()->setDiscoveryStrategy(new RoundRobinStrategy());
```

### Local Registry and Caching

[](#local-registry-and-caching)

Failure is inevitable, specially in cloud-native applications. Thus, sometimes Eureka may not be available because of failure. In these cases, we should have a local registry of services to avoid cascading failures.

By default, if Eureka is down, the `fetchInstance()` method fails, so an exception would be thrown and the application cannot continue to work. To solve this problem, you should create a local registry of services.

There is an interface called `InstanceProvider` which you can make use of, by implementing `getInstances()` method of this interface and returning instances of a service based on your ideal logic.

```
class MyProvider implements InstanceProvider {

    public function getInstances($appName) {
        // return cached instances of the service from the Redis
    }
}
```

In this example, we have cached the instances of the service in the Redis and are loading them when Eureka is down.

After creating your custom provider, just make it work by adding it to the configuration:

```
$client->getConfig()->setInstanceProvider(new MyProvider());
```

Your custom provider only gets called when Eureka is down or is not answering properly.

That's all you need to do. By adding this functionality, your application keeps working even when Eureka is down.

For caching all available instances of a specific service, you can call `fetchInstances()` method which fetches all of the instances of the service from Eureka:

```
$instances = $client->fetchInstances("the-service");
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

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

Unknown

Total

1

Last Release

1370d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6149996b422816e9df76c9d3f45f830ff63d3b5d685375dbdfff8a56ed408cac?d=identicon)[APU-SteveRogers](/maintainers/APU-SteveRogers)

---

Top Contributors

[![piwvh](https://avatars.githubusercontent.com/u/7631027?v=4)](https://github.com/piwvh "piwvh (20 commits)")[![thiagobit](https://avatars.githubusercontent.com/u/2165422?v=4)](https://github.com/thiagobit "thiagobit (1 commits)")[![xnkjj](https://avatars.githubusercontent.com/u/16268065?v=4)](https://github.com/xnkjj "xnkjj (1 commits)")

---

Tags

phpeurekaspring clouddiscovery server

### Embed Badge

![Health badge](/badges/apu-php-eureka-server/health.svg)

```
[![Health](https://phpackages.com/badges/apu-php-eureka-server/health.svg)](https://phpackages.com/packages/apu-php-eureka-server)
```

###  Alternatives

[piwvh/php-eureka

A PHP client for Spring Cloud Eureka discovery server.

7558.0k1](/packages/piwvh-php-eureka)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[mailchimp/transactional

458.9M16](/packages/mailchimp-transactional)[resend/resend-php

Resend PHP library.

574.7M21](/packages/resend-resend-php)[scriptdevelop/whatsapp-manager

Paquete para manejo de WhatsApp Business API en Laravel

762.6k](/packages/scriptdevelop-whatsapp-manager)

PHPackages © 2026

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