Winter Eureka: Service Discovery Module
Winter Eureka is a module that provides easy configuration and access to service discovery functionality from Winter Boot applications. It supports both Consul.io and Netflix Eureka, and requires the swoole PHP extension.
-
Install the swoole extension
Winter Eureka requires the
swoolePHP extension. Make sure it is installed and enabled in your environment before proceeding. -
Install the package
Terminal window composer require suvera/winter-eureka -
Enable the module
Append the following block to your
application.yml:modules:- module: dev\winterframework\eureka\EurekaModuleenabled: trueconfigFile: eureka-config.ymlThe
configFilevalue is a file path, either relative to the config directory or an absolute path.
eureka-config.yml
Section titled “eureka-config.yml”Create eureka-config.yml in your config directory. The file supports configuring connections for both Consul.io and Netflix Eureka.
# Consul.ioconsul: - name: consulBean01 serviceUrl: http://127.0.0.1:8500 authType: Basic credentials: credentialFile: dataCenter: waitTimeSecs: consulToken: consulTokenFile: ignoreSsl: caFile: certFile: keyFile:
# Netflix Eurekaeureka: - name: netflixBean01 serviceUrl: http://localhost:8761/eureka authType: Basic credentials: credentialFile: ignoreSsl:
# EndAutowiring
Section titled “Autowiring”Service and client beans defined in eureka-config.yml can be autowired into your PHP classes:
#[Autowired('consulBean01')]protected DiscoveryClient $discoveryClient;
#[Autowired('netflixBean01')]protected EurekaClient $eurekaClient;For details on the module system, refer to The Module System.