All Projects → dcarbone → php-consul-api

dcarbone / php-consul-api

Licence: Apache-2.0 license
PHP client implementation for the Consul API

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to php-consul-api

consul-api-gateway
The Consul API Gateway is a dedicated ingress solution for intelligently routing traffic to applications running on a Consul Service Mesh.
Stars: ✭ 88 (+17.33%)
Mutual labels:  consul
hubble
hubbling the universe nebula by nebula
Stars: ✭ 18 (-76%)
Mutual labels:  consul
Uragano
Uragano, A simple, high performance RPC library. Support load balancing, circuit breaker, fallback, caching, intercepting.
Stars: ✭ 28 (-62.67%)
Mutual labels:  consul
sample-kotlin-ktor-microservices
sample microservices written in Kotlin that demonstrates usage of Ktor framework woth Consul server
Stars: ✭ 37 (-50.67%)
Mutual labels:  consul
hashicorp-labs
Deploy locally on VM an Hashicorp cluster formed by Vault, Consul and Nomad. Ready for deploying and testing your apps.
Stars: ✭ 32 (-57.33%)
Mutual labels:  consul
share
基于 go + grpc + consul 的微服务系统
Stars: ✭ 24 (-68%)
Mutual labels:  consul
rabbitmq-peer-discovery-consul
Consul-based peer discovery backend for RabbitMQ 3.7.0+
Stars: ✭ 39 (-48%)
Mutual labels:  consul
katalog-sync
A reliable node-local mechanism for syncing k8s pods to consul services
Stars: ✭ 34 (-54.67%)
Mutual labels:  consul
nomad-service-alerter
Alerting for Nomad Jobs
Stars: ✭ 37 (-50.67%)
Mutual labels:  consul
rocketmq-client-php
A Php Client for Apache RocketMQ.
Stars: ✭ 80 (+6.67%)
Mutual labels:  php-client
consul role
Ansible role to install Consul (cluster of) server/agent
Stars: ✭ 14 (-81.33%)
Mutual labels:  consul
consul-acl-client-tutorial
Example how to configure and use Consul client agent with ACL
Stars: ✭ 26 (-65.33%)
Mutual labels:  consul
servicestack-configuration-consul
An implementation of ServiceStack IAppSettings interface that uses Consul.io key/value store as backing storage
Stars: ✭ 17 (-77.33%)
Mutual labels:  consul
vault-consul-kubernetes
vault + consul on kubernetes
Stars: ✭ 60 (-20%)
Mutual labels:  consul
bol-retailer-php-client
PHP Client library for Bol.com Retailer API
Stars: ✭ 19 (-74.67%)
Mutual labels:  php-client
perseus
Perseus is a set of scripts (docker+javascript) to investigate a distributed database's responsiveness when one of its three nodes is isolated from the peers
Stars: ✭ 49 (-34.67%)
Mutual labels:  consul
getting-into-consul
A zero to complete walk through of setting up HashiCorp Consul on AWS from scratch!
Stars: ✭ 56 (-25.33%)
Mutual labels:  consul
MySQLSandbox
MySQLSandbox with orchestrator in docker
Stars: ✭ 13 (-82.67%)
Mutual labels:  consul
hrpc
A simple Java RPC framework based on Spring, Netty, Protobuf and Consul
Stars: ✭ 34 (-54.67%)
Mutual labels:  consul
hookpick
A tool to manage some operational concepts of Hashicorp Vault
Stars: ✭ 83 (+10.67%)
Mutual labels:  consul

php-consul-api

Tests

PHP client for the Consul HTTP API

This library is loosely based upon the official GO client.

Version Compatibility

PHPConsulAPI Version Consul Version
0.3.x 0.6.4
0.6.x 0.7-0.8
v1.x 0.9-current
dev-master current

Newer versions of the api lib will probably work in a limited capacity with older versions of Consul, but no guarantee is made and backwards compatibility issues will not be addressed.

Composer

This lib is designed to be used with Composer

Require Entry:

{
    "require": {
        "dcarbone/php-consul-api": "^v1.0"
    }
}

Configuration

First, construct a Config. This class is modeled quite closely after the Config Struct present in the Consul API Subpackage.

Default Configuration

If you have defined some of the Consul Environment Variables on your hosts then it would probably be easiest to simply execute the following:

$config = \DCarbone\PHPConsulAPI\Config::newDefaultConfig();

Advanced Configuration

You may alternatively define values yourself:

$config = new \DCarbone\PHPConsulAPI\Config([
    'HttpClient' => $client,            // [required] Client conforming to GuzzleHttp\ClientInterface
    'Address' => 'address of server',   // [required]

    'Scheme' => 'http or https',            // [optional] defaults to "http"
    'Datacenter' => 'name of datacenter',   // [optional]
    'HttpAuth' => 'user:pass',              // [optional]
    'WaitTime' => '0s',                     // [optional] amount of time to wait on certain blockable endpoints.  go time duration string format. 
    'Token' => 'auth token',                // [optional] default auth token to use
    'TokenFile' => 'file with auth token',  // [optional] file containing auth token string
    'InsecureSkipVerify' => false,          // [optional] if set to true, ignores all SSL validation
    'CAFile' => '',                         // [optional] path to ca cert file, see http://docs.guzzlephp.org/en/latest/request-options.html#verify
    'CertFile' => '',                       // [optional] path to client public key.  if set, requires KeyFile also be set
    'KeyFile' => '',                        // [optional] path to client private key.  if set, requires CertFile also be set
    'JSONEncodeOpts'=> 0,                   // [optional] php json encode opt value to use when serializing requests
]);

Configuration Note:

By default, this client will attempt to locate a series of environment variables to describe much of the above configuration properties. See here for that list, and see here for a list of the env var names.

For more advanced client configuration, such as proxy configuration, you must construct your own GuzzleHttp client prior to constructing a PHPConsulAPI Config object.

As an example:

$proxyClient = new \GuzzleHttp\Client(['proxy' => 'whatever proxy you want']]);
$config = new \DCarbone\PHPConsulAPI\Config([
    'HttpClient' => $proxyClient,
    'Address' => 'address of server',
]);

When constructing your client, if you are using the GuzzleHttp\Client object directly or derivative thereof, you may pass any option listed in the Guzzle Request Options.

Consul

Next, construct a Consul object:

$consul = new \DCarbone\PHPConsulAPI\Consul($config);

NOTE: If you do not create your own config object, Consul will create it's own using Config::newDefaultConfig() and attempt to locate a suitable HTTP Client.

Once constructed, you interact with each Consul API via it's corresponding Client class:

$kvResp = $consul->KV->Keys();
if (null !== $kvResp->Err)
    die($kvResp->Err);

var_dump($kvResp->Value);

...as an example.

Current Clients

More will be added as time goes on!

Tests

The testing suite is still in it's infancy, however it is being tested directly against an actual Consul agent. They will be back-filled as time allows. Future plans are to set up a simple cluster to provide a more real-world testing scenario.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].