Download the PHP package tourze/redis-dedicated-connection-bundle without Composer
On this page you can find all versions of the php package tourze/redis-dedicated-connection-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tourze/redis-dedicated-connection-bundle
More information about tourze/redis-dedicated-connection-bundle
Files in tourze/redis-dedicated-connection-bundle
Package redis-dedicated-connection-bundle
Short Description 为服务自动创建和注入专用的 Redis 连接,支持属性、标签、环境变量等多种配置方式
License MIT
Informations about the package redis-dedicated-connection-bundle
Redis Dedicated Connection Bundle
中文
This bundle provides automatic creation and injection of dedicated Redis connections for Symfony services, supporting attributes, tags, and environment variable configuration.
Table of Contents
- Features
- Dependencies
- Installation
- Usage
- Method 1: Using PHP Attributes
- Method 2: Using Service Tags
- Method 3: Using Connection Channel Tags
- Method 4: Using the Helper Class
- Configuration
- Environment Variables
- Method 1: Using Redis URL (Recommended)
- Method 2: Using Individual Parameters
- Available Environment Variables
- Advanced Usage
- Multiple Connections for One Service
- Direct Connection Reference
- Checking Connection Existence
- Testing
- Security
- Contributing
- Running Tests
- Reporting Issues
- License
Features
- Automatic Connection Creation: Automatically creates Redis connections based on service requirements
- Multiple Configuration Methods: Support for PHP attributes, service tags, and environment variables
- Connection Isolation: Each service can have its own dedicated Redis connection
- Coroutine Support: Proper connection management in coroutine environments
- Flexible Configuration: Support for single instance, cluster, and replication modes
Dependencies
- PHP 8.1 or higher
- Symfony 6.4 or higher
- PHP Redis extension
- tourze/symfony-runtime-context-bundle
Installation
Note: This bundle requires the PHP Redis extension to be installed:
Usage
Method 1: Using PHP Attributes
Method 2: Using Service Tags
Method 3: Using Connection Channel Tags
Method 4: Using the Helper Class
Configuration
Environment Variables
The bundle supports two ways to configure Redis connections:
Method 1: Using Redis URL (Recommended)
Configure connections using Redis URLs following the official Redis URI scheme:
Supported query parameters in URLs:
timeout- Connection timeout in secondsread_write_timeout- Read/write timeout in secondspersistent- Use persistent connection (true/false)prefix- Key prefix for all operations
Method 2: Using Individual Parameters
Configure connections using individual environment variables with the pattern
{CHANNEL}_REDIS_{OPTION}:
Note: Individual parameters take precedence over URL parameters if both are specified.
Available Environment Variables
For each channel, you can configure:
{CHANNEL}_REDIS_URL: Redis connection URL (takes precedence if set){CHANNEL}_REDIS_HOST: Redis host (default: 127.0.0.1){CHANNEL}_REDIS_PORT: Redis port (default: 6379){CHANNEL}_REDIS_DB: Database number (default: 0){CHANNEL}_REDIS_PASSWORD: Connection password{CHANNEL}_REDIS_TIMEOUT: Connection timeout in seconds (default: 5.0){CHANNEL}_REDIS_READ_WRITE_TIMEOUT: Read/write timeout (default: 0.0){CHANNEL}_REDIS_PERSISTENT: Use persistent connections (default: false){CHANNEL}_REDIS_PREFIX: Key prefix for all operations
For the default channel, you can also use the global REDIS_URL environment variable.
Advanced Usage
Multiple Connections for One Service
Direct Connection Reference
Checking Connection Existence
Testing
Run the test suite:
Note: Integration tests require a running Redis server. If Redis is not available, these tests will be skipped.
Security
Security Considerations
When using this bundle, please consider the following security aspects:
-
Environment Variables: Never commit Redis credentials to version control. Use environment variables or secure configuration management systems.
-
Network Security:
- Use SSL/TLS connections (rediss://) for production environments
- Restrict Redis server access to trusted networks only
- Configure Redis authentication and ACLs properly
-
Data Encryption: This bundle does not encrypt data at the application level. Consider encrypting sensitive data before storing it in Redis.
- Connection Limits: Configure appropriate connection limits to prevent resource exhaustion attacks.
Reporting Security Vulnerabilities
If you discover a security vulnerability, please send an email to [email protected] instead of creating a public issue. All security vulnerabilities will be promptly addressed.
Contributing
We welcome contributions! Please see our contributing guidelines for details.
Running Tests
Before submitting a pull request, please ensure:
- All tests pass:
./vendor/bin/phpunit packages/redis-dedicated-connection-bundle/tests - Code follows PSR standards:
./vendor/bin/php-cs-fixer fix packages/redis-dedicated-connection-bundle - Static analysis passes:
./vendor/bin/phpstan analyse packages/redis-dedicated-connection-bundle
Reporting Issues
If you discover a bug or have a feature request, please create an issue on our GitHub repository.
License
This bundle is licensed under the MIT License. See the LICENSE file for details.
All versions of redis-dedicated-connection-bundle with dependencies
ext-redis Version *
monolog/monolog Version ^3.1
psr/log Version ^3|^2|^1
symfony/config Version ^7.3
symfony/dependency-injection Version ^7.3
symfony/framework-bundle Version ^7.3
symfony/http-kernel Version ^7.3
symfony/property-access Version ^7.3
symfony/yaml Version ^7.3
tourze/bundle-dependency Version 1.*
tourze/symfony-dependency-service-loader Version 1.0.*
tourze/symfony-runtime-context-bundle Version 1.0.*