This file provides AI agents and developers with the minimum but sufficient context to work productively with the Valkey GLIDE PHP client. It covers build commands, testing, contribution requirements, and essential guardrails specific to the PHP implementation.
This is the PHP client binding for Valkey GLIDE, providing a sync client implementations. The PHP client is intended to have the same programming interface as PHPRedis, differing only when constructing instances of the client (standalone and cluster). It is implemented as a Zend extension.
Primary Languages: PHP, C (Zend Framework) Build System: Standard automake-based system for Zend extensions. phpize, configure, make, make install. Architecture: PHP API stubs implemented using the Zend Framework in C. Implementations delegate communication to the GLIDE Core written in Rust using C FFI headers.
Key Components:
./- PHP API stubs (*.php.stub files),src/- Mock classes for testing.tests/- Test suite (primarily integration tests)config.m4andMakefile.frag- Templates for configure and Makefilepackage.xml- File manifest for PECL packagescomposer.json- Manifest for PIE packagesvalkey-glide/- submodule reference to the valkey-glide repo for the GLIDE core.
Core Implementation: C wrappers around glide-core Rust library exposed through PHP's Zend framework. Client Types: ValkeyGlide and ValkeyGlideCluster represent standalone and cluster clients respectively. API Styles: Blocking API, matching PHPRedis. Communication: Direct FFI (sync)
Supported Platforms:
- Linux: Ubuntu 20+, Amazon Linux 2/2023 (x86_64, aarch64)
- macOS: 13.7+ (x86_64), 14.7+ (aarch64)
- Note: Alpine Linux/MUSL not supported
PHP Versions: 8.1, 8.2
Packages: valkey-io/valkey-glide-php
- Client constructors are implemented with the by implementing
__constructPHP method for a class using the PHP_METHOD macro. Seevalkey_glide.candvalkey_glide_cluster.c - The design of the clusters basically marshal PHP function arguments to C structs defined locally, then those get written to protobufs messages defined by the FFI layer. Then create_client() is called in the FFI layer with the protobuf message.
- The C structures representing the connection configuration are
valkey_glide_client_configuration_tandvalkey_glide_cluster_client_configuration_t. Shared fields are invalkey_glide_base_client_configuration_t. - The method which converts the configuration to protobuf is
create_connection_request()defined invalkey_glide_core_commands.c.
- Define a method in
valkey_glide.stub.phpand/orvalkey_glide_cluster.stub.phpdepending on if it should be available in standalone or cluster. - Write a helper function to execute the command through the FFI layer. See
execute_get_commandfor an example. These methods should work generically on aValkeyGlideorValkeyGlideCluster. Thevalkey_glide_objectpointer represents either. - Define a macro that invokes the PHP_METHOD macro, taking in a class name. Have that macro call the helper above. See
GET_METHOD_IMPL. - Invoke this macro in a .c file.
valkey_z_php_methods.cfor standalone andvalkey_glide_cluster.cfor cluster.
- Files are named
valkey_glide_<command_category>_commands.c, possibly with a numerical suffix. - Code to be shared across a command category go in
valkey_glide_<command_category>_common.c.
Tests are written using a proprietary test framework rather than an existing framework such as PHPUnit. The base class for test suites is TestSuite and it is in tests/TestSuite.php. This framework doesn't integrate into IDEs such as PhpStorm and doesn't provide a way to run individual test methods or by pattern so switching to a well-known framework may be beneficial.
# Build commands
phpize
./configure
make
# Testing
make test
## Contribution Requirements
### Developer Certificate of Origin (DCO) Signoff REQUIRED
All commits must include a `Signed-off-by` line:
```bash
# Add signoff to new commits
git commit -s -m "feat(python): add new command implementation"
# Configure automatic signoff
git config --global format.signOff true
# Add signoff to existing commit
git commit --amend --signoff --no-edit
# Add signoff to multiple commits
git rebase -i HEAD~n --signoffUse conventional commit format:
<type>(<scope>): <description>
[optional body]
Example: feat(python): implement async cluster scan with routing options
# All linters
./lint.sh # Check
./lint.sh --fix # Fix
# C code only
./lint-c.sh # Check
./lint-c.sh --fix # Fix
# PHP code only
./lint-php.sh # Check
./lint-php.sh --fix # FixSee the .gitignore
- Build passes:
phpize, ./configure, makesucceeds - All tests pass:
make testsucceeds - Linting passes:
./lint.shdoes not report warnings - No generated outputs committed (check
.gitignore) - DCO signoff present:
git log --format="%B" -n 1 | grep "Signed-off-by" - Conventional commit format used
- Documentation follows Google Style format
Packages: valkey-glide (async), valkey-glide-sync (sync) on PyPI
API Styles: Async (asyncio/trio), Sync (blocking)
Client Types: GlideClient (standalone), GlideClusterClient (cluster) for both async/sync
Key Features: Dual client architecture, shared logic, multi-async framework support
Testing: pytest with async backend selection, shared test suite
Platforms: Linux (Ubuntu, AL2/AL2023), macOS (Intel/Apple Silicon)
Dependencies: Python 3.9+, Rust toolchain, protobuf compiler
- Getting Started: README.md
- Development Setup: DEVELOPER.md
- Examples: ../examples/
- Test Suites: tests/ directory