Lightweight CONSUL service discovery for PHP
You need to have CONSUL agent up and running.
This library can be installed with composer:
composer require jcalderonzumba/consul-discovery
The usage depends on the feature of CONSUL you want to use, for the moment we support:
- Service discovery
Discovery of a service was never easier just use:
use Zumba\Consul\Features\Discovery;
$discovery = new Discovery([
"consul_url" => "YOUR_CONSUL_HTTP_API"
]);
$service = $discovery->getService("pigeon");
echo $service->getID();
echo $service->getAddress();
echo $service->getPort();
By default we search ONLY for healthy service nearest to the agent. If you want this behavior to change open a issue and let's talk about it.
- TEST, TEST, TEST!!!
- Add more features to the SDK.