Skip to content

Winter Eureka: Service Discovery Module

Winter Eureka connects Winter Boot applications to a service registry. It supports both Consul.io and Netflix Eureka, and requires the swoole PHP extension.

  1. Install the prerequisites

    Winter Eureka requires the swoole PHP extension plus the suvera/winter-eureka package. Follow the Installation guide (Docker is recommended) to set them up.

  2. Enable the module

    Append the following block to your application.yml:

    application.yml
    modules:
    - module: dev\winterframework\eureka\EurekaModule
    enabled: true
    configFile: eureka-config.yml

    The configFile value is a file path, either relative to the config directory or an absolute path.

Create eureka-config.yml in your config directory. The file supports configuring connections for both Consul.io and Netflix Eureka.

config/eureka-config.yml
# Consul.io
consul:
- name: consulBean01
serviceUrl: http://127.0.0.1:8500
authType: Basic
credentials:
credentialFile:
dataCenter:
waitTimeSecs:
consulToken:
consulTokenFile:
ignoreSsl:
caFile:
certFile:
keyFile:
# Netflix Eureka
eureka:
- name: netflixBean01
serviceUrl: http://localhost:8761/eureka
authType: Basic
credentials:
credentialFile:
ignoreSsl:

Each entry in eureka-config.yml becomes a bean named after its name. Autowire it by that name:

#[Autowired('consulBean01')]
protected DiscoveryClient $discoveryClient;
#[Autowired('netflixBean01')]
protected EurekaClient $eurekaClient;

For details on the module system, refer to The Module System.