friendsofphp/consul-php-sdk
PHP SDK for HashiCorp Consul by FriendsOfPHP. Provides a clean API client to interact with Consul’s HTTP endpoints—service discovery, KV store, health checks, sessions, ACL, and agent/catalog operations—usable in any PHP app or framework.
register() for SDK init, boot() for service binding).cache:store consul) or Redis for distributed configs.cache facade).env)?cache facade) needed for KV operations?Consul::agent()->checks()).env with Consul KV for dynamic configs (e.g., feature flags).api, queue-worker).| Phase | Task | Tools/Libraries |
|---|---|---|
| Discovery | Register Laravel services in Consul. | consul-php-sdk, Laravel Service Provider |
| Config | Migrate static configs to Consul KV store. | cache:store consul (custom driver) |
| Health | Add health checks for Laravel services. | Consul Agent API |
| Orchestration | Use Consul for leader election (e.g., Horizon workers). | KV store + Watchers |
| Security | Implement Consul ACLs for service auth. | Consul Enterprise (if needed) |
| Monitoring | Export Consul metrics to Prometheus/Grafana. | Consul HTTP API |
consul-php-sdk's logging (PSR-3 compatible).Index headers for KV watches.connect_timeout in SDK config.interval).| Failure Scenario | Impact | Mitigation Strategy |
|---|---|---|
| Consul Server Down | Service discovery fails. | Fallback to local config + alerts. |
| Network Partition | KV store inconsistencies. | Use Consul’s WriteStale for writes. |
| API Rate Limiting | Health checks time out. | Implement exponential backoff. |
| ACL Misconfiguration | Services can’t register. | Audit ACLs via consul acl token self. |
| SDK Bug | API calls fail silently. | Add circuit breakers (e.g., Predis-style). |
How can I help you explore Laravel packages today?