laruence/yaconf
FreeA PHP Persistent Configurations Container
FreeFree tier
About laruence/yaconf
Yaconf is a PHP extension that provides a persistent configurations container. It parses INI files at PHP startup and stores the configuration data in memory for the entire PHP lifecycle, enabling extremely fast access with zero-copy reads. Yaconf supports sections and section inheritance, automatic configuration reload on file changes, and can interpret PHP constants and environment variables within configuration values. It offers a simple API with Yaconf::get() and Yaconf::has() methods for retrieving configuration values by dot-notation keys. Designed for PHP 7+, it is a lightweight and efficient solution for managing application configuration.
Key Features
Parses INI configuration files at PHP startup
Zero-copy access to configuration values
Supports sections and section inheritance
Auto-reloads configuration when files change
Supports PHP constants and environment variables in config values
Simple API with Yaconf::get() and Yaconf::has() methods
Lightweight and high performance
Pros & Cons
Pros
- Extremely fast due to zero-copy and persistent storage
- Lightweight and minimal overhead
- Automatic detection and reload of changed configuration files
- Supports hierarchical configuration with sections inheritance
- Can use PHP constants and environment variables in config values
Cons
- Requires PHP 7+ and installation as a PECL extension
- Configuration changes require PHP process restart or check_delay setting
- No built-in support for configuration validation or schema enforcement
- Only supports INI file format
Best For
Centralized configuration management for PHP applicationsHigh-performance configuration container for production environmentsManaging environment-specific settings with section inheritancePersistent configuration accessible across the entire PHP lifecycle
FAQ
What is Yaconf?
Yaconf (Yet Another Configurations Container) is a PHP extension that parses INI files and stores the configuration persistently in PHP memory for the entire PHP lifecycle, providing fast zero-copy access.
How do I install Yaconf?
Yaconf can be installed via PECL: `pecl install yaconf`, or compiled from source using phpize and standard build commands.
How do I use Yaconf to get configuration values?
Use `Yaconf::get('key')` to retrieve a value by dot-notation (e.g., 'foo.name'), or `Yaconf::has('key')` to check if a key exists. A default value can be provided as the second parameter.
Does Yaconf support configuration reloading?
Yes, Yaconf can automatically detect and reload configuration files based on the `yaconf.check_delay` runtime setting, which checks directory mtime at a specified interval. If set to zero, reload requires a PHP restart.
What types of values can Yaconf parse?
Yaconf supports strings, numbers, arrays (maps), PHP constants, and environment variables within INI configuration files.