Download the PHP package togomq/togomq-sdk without Composer
On this page you can find all versions of the php package togomq/togomq-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download togomq/togomq-sdk
More information about togomq/togomq-sdk
Files in togomq/togomq-sdk
Package togomq-sdk
Short Description Official PHP SDK for TogoMQ - A modern, high-performance message queue service
License MIT
Homepage https://togomq.io
Informations about the package togomq-sdk
TogoMQ SDK for PHP
The official PHP SDK for TogoMQ - a modern, high-performance message queue service. This SDK provides a simple and intuitive API for publishing and subscribing to messages using gRPC streaming.
Features
- 🚀 High Performance: Built on gRPC for efficient communication
- 📡 Streaming Support: Native support for streaming pub/sub operations
- 🔒 Secure: TLS encryption and token-based authentication
- 🎯 Simple API: Easy-to-use client with fluent configuration
- 📝 Comprehensive Logging: Configurable log levels for debugging
- ⚡ Modern PHP: Requires PHP 8.1+ with strict typing
- ✅ Well Tested: Comprehensive test coverage
Requirements
- PHP 8.1 or higher
- gRPC PHP extension
- Access to a TogoMQ server
- Valid TogoMQ authentication token
Installation
Install the SDK using Composer:
Make sure you have the gRPC PHP extension installed:
Configuration
The SDK supports flexible configuration with sensible defaults:
Default Configuration
Configuration Options
| Option | Default | Description |
|---|---|---|
| Host | q.togomq.io | TogoMQ server hostname |
| Port | 5123 | TogoMQ server port |
| LogLevel | info | Logging level (debug, info, warn, error, none) |
| Token | (required) | Authentication token |
Custom Configuration
Usage
Publishing Messages
Publishing a Batch of Messages
Subscribing to Messages
Basic Subscription
Advanced Subscription with Options
Subscription Options:
- Batch: Maximum number of messages to receive at once (default: 0 = server default 1000)
- SpeedPerSec: Rate limit for message delivery per second (default: 0 = unlimited)
Subscribe to All Topics (Wildcard)
Subscribe with Pattern Wildcards
Subscription with Error Handling
Message Structure
Publishing Message
Important: Topic is required when publishing messages.
Received Message
Error Handling
The SDK provides detailed error information:
Error Codes
ERR_CODE_CONNECTION- Connection or network errorsERR_CODE_AUTH- Authentication failuresERR_CODE_VALIDATION- Invalid input or configurationERR_CODE_PUBLISH- Publishing errorsERR_CODE_SUBSCRIBE- Subscription errorsERR_CODE_STREAM- General streaming errorsERR_CODE_CONFIGURATION- Configuration errors
Logging
Control logging verbosity with the logLevel configuration:
Log levels:
debug- All logs including debug informationinfo- Informational messages and abovewarn- Warnings and errors onlyerror- Error messages onlynone- Disable logging
Best Practices
- Reuse Clients: Create one client per application and reuse it across requests
- Handle Errors: Always check and handle errors appropriately
- Close Connections: Always call
$client->close()when done - Batch Messages: Use
pubBatch()for better performance when publishing multiple messages - Monitor Subscriptions: Use try-catch blocks to handle subscription errors gracefully
- Validate Topics: Always provide valid topic names for both publishing and subscribing
Examples
Check out the examples/ directory for complete working examples:
examples/publish.php- Publishing examplesexamples/subscribe.php- Subscription examples
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- Documentation: https://togomq.io/docs
- Issues: https://github.com/TogoMQ/togomq-sdk-php/issues
- TogoMQ Website: https://togomq.io
Related Projects
- togomq-grpc-php - Auto-generated gRPC protobuf definitions
- togomq-sdk-go - TogoMQ SDK for Go TogoMQ SDK library for PHP
All versions of togomq-sdk with dependencies
togomq/togomq-grpc Version dev-main
grpc/grpc Version ^1.57
psr/log Version ^3.0