PHP Conference Ehime 2026

Yaconf

Introduction

Yet Another Configurations Container (Yaconf) is a configuration container. It parses INI files when PHP starts up and keeps the result in persistent memory for the whole PHP lifecycle, so every retrieval is a fast hash lookup with no file I/O and no per-request parsing.

Yaconf stores all configurations as interned strings or immutable arrays. They are not refcounted, so retrieving a configuration from Yaconf is effectively zero-copy. Since Yaconf 1.2.0, the whole parsed configuration tree is additionally compacted into a single contiguous block, which lowers memory overhead and improves cache locality.

The parsed configuration lives in persistent memory shared by all PHP-FPM workers through copy-on-write: until a configuration file changes, the workers share the same physical memory pages no matter how many of them are running.

Yaconf supports sections and section inheritance in INI files. On non-ZTS builds it also reloads the files automatically when they change; on ZTS (thread-safe) builds, configurations are loaded at startup and a restart is required to pick up changes.

Since Yaconf 1.2.0, sub-directories of the configured directory are loaded recursively (up to 16 levels deep) and addressed with the directory name as a key level: for example, Yaconf::get("users.database.master") reads the master key from the file database.ini placed in the users/ sub-directory.

Storing sensitive configurations outside the web tree also lowers the attack surface. Configuration files under the web root can be retrieved by an attacker, for example through a file disclosure vulnerability. With Yaconf, the .ini files can instead be placed in a directory readable only by root, such as /etc/yaconf: the PHP-FPM master loads the configurations when the service starts, while the forked workers — which run under an unprivileged user and are the ones executing web requests — do not need, and are not given, access to that directory.

Yaconf requires PHP 7.0 or greater.

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top