Download the PHP package vartroth/secrets-manager without Composer
On this page you can find all versions of the php package vartroth/secrets-manager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download vartroth/secrets-manager
More information about vartroth/secrets-manager
Files in vartroth/secrets-manager
Download vartroth/secrets-manager
More information about vartroth/secrets-manager
Files in vartroth/secrets-manager
Vendor vartroth
Package secrets-manager
Short Description A PHP package to manage Docker secrets and environment variables
License MIT
Package secrets-manager
Short Description A PHP package to manage Docker secrets and environment variables
License MIT
Please rate this library. Is it a good library?
Informations about the package secrets-manager
Secrets Manager for PHP
A robust PHP package for managing Docker secrets and environment variables with caching, flexible configuration, and a clean API.
Features
- ๐ณ Docker Secrets Support: Read secrets from Docker secrets files (
/run/secrets) - ๐ Environment Variables: Load secrets from environment variables
- โก Caching: Optional in-memory caching for improved performance
- ๐ง Flexible Configuration: Configurable precedence, prefixes, and paths
- ๐ก๏ธ Security: Path traversal protection and input validation
- ๐ฆ Multiple Interfaces: Object-oriented and static facade patterns
- ๐งช Testing Friendly: Easy mocking and manual secret injection
Installation
Quick Start
Basic Usage
Static Facade
Configuration
Using SecretsConfig
Configuration Options
| Option | Description | Default |
|---|---|---|
secretsPath |
Path to Docker secrets directory | /run/secrets |
enableCache |
Enable in-memory caching | true |
envPrefix |
Prefix for environment variables | '' (none) |
envPrecedence |
Environment variables take precedence | true |
How It Works
The SecretsManager follows this lookup order (when envPrecedence is true):
- Environment Variables: Checks
$_ENV,$_SERVER, andgetenv() - Docker Secrets: Reads from files in the secrets directory
- Default Value: Returns provided default or throws exception
When envPrecedence is false, Docker secrets are checked first.
Environment Variables
With prefix APP_:
- Secret name:
database_url - Environment variable:
APP_database_url
Without prefix:
- Secret name:
database_url - Environment variable:
database_url
Docker Secrets
Secrets are read from files in the configured directory:
- Secret name:
database_url - File path:
/run/secrets/database_url
API Reference
SecretsManager
Core Methods
Cache Management
Configuration Getters
Secrets (Static Facade)
Docker Integration
Docker Compose Example
Dockerfile
Error Handling
The package throws specific exceptions for different error conditions:
Testing
PHPUnit Example
Mock Secrets
Security Considerations
- Path Traversal Protection: The package validates that secret paths stay within the configured directory
- File Permissions: Ensures secret files are readable before attempting to read them
- No Logging: Secret values are never logged or exposed in error messages
- Memory Management: Secrets can be cleared from memory when no longer needed
Performance
- Caching: Enabled by default, secrets are cached in memory after first access
- Lazy Loading: Secrets are only read when requested
- Batch Operations:
getMultiple()andgetAll()methods for efficient bulk operations
Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature/new-feature - Make your changes and add tests
- Run tests:
composer test - Run static analysis:
composer analyse - Submit a pull request
Requirements
- PHP 8.0 or higher
- No external dependencies for core functionality
License
MIT License. See LICENSE file for details.
Changelog
v0.1.0
- Initial release
- Docker secrets support
- Environment variables support
- Caching functionality
- Static facade
- Comprehensive test suite
All versions of secrets-manager with dependencies
PHP Build Version
Package Version
Requires
php Version
>=8.1
The package vartroth/secrets-manager contains the following files
Loading the files please wait ...