A simple and professional PHP client for Zentropy. Supports TCP connections with authentication and Unix socket connections.
- Connect to Zentropy server over TCP or Unix socket.
- Optional password authentication for TCP connections.
- Common commands:
SET
,GET
,DELETE
,EXISTS
,PING
. - Easy to integrate in any PHP project, including Laravel.
- Minimal dependencies, PSR-4 autoloading.
Use Composer to install:
composer require mailmug/zentropy-php
<?php
require 'vendor/autoload.php';
use Zentropy\Client;
$client = Client::tcp('127.0.0.1', 6383, 'pass@123');
$client->set('foo', 'bar');
echo $client->get('foo'); // Outputs: bar
$client->close();
<?php
require 'vendor/autoload.php';
use Zentropy\Client;
$client = Client::unixSocket('/tmp/zentropy.sock');
$client->set('foo', 'bar');
echo $client->get('foo'); // Outputs: bar
$client->close();
Method | Description |
---|---|
Client::tcp($host, $port, $password) |
Create a TCP client with optional password. |
Client::unixSocket($path) |
Create a client using a Unix socket. |
set(string $key, string $value) |
Set a key-value pair. |
get(string $key) |
Get the value of a key. Returns null if key doesn't exist. |
delete(string $key) |
Delete a key. Returns true if successful. |
exists(string $key) |
Check if a key exists. |
ping() |
Ping the server. Returns true if alive. |
close() |
Close the connection. |
auth(string $password) |
Authenticate TCP connection (internal for TCP only). |
-
Fork the repository.
-
Run composer install.
-
Add tests in tests/ and examples in examples/.
-
Submit a pull request.