<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/refs.basic.other.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'book.yaconf.php',
    1 => 'Yaconf',
    2 => 'Yaconf',
  ),
  'up' => 
  array (
    0 => 'refs.basic.other.php',
    1 => 'Other Basic Extensions',
  ),
  'prev' => 
  array (
    0 => 'class.yaf-exception-loadfailed-view.php',
    1 => 'Yaf_Exception_LoadFailed_View',
  ),
  'next' => 
  array (
    0 => 'yaconf.setup.php',
    1 => 'Installing/Configuring',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/yaconf/book.xml',
  ),
  'history' => 
  array (
  ),
  'extra_header_links' => 
  array (
    'rel' => 'alternate',
    'href' => '/manual/en/feeds/book.yaconf.atom',
    'type' => 'application/atom+xml',
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="book.yaconf" class="book">
 
 <h1 class="title">Yaconf</h1>
 

 <div id="intro.yaconf" class="preface">
  <h1 class="title">Introduction</h1>
  <p class="simpara">
   <code class="literal">Yet Another Configurations Container</code>
   (<abbr>Yaconf</abbr>) is a configuration container. It parses
   <code class="literal">INI</code> 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.
  </p>
  <p class="simpara">
   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.
  </p>
  <p class="simpara">
   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.
  </p>
  <p class="simpara">
   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.
  </p>
  <p class="simpara">
   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,
   <code class="literal">Yaconf::get(&quot;users.database.master&quot;)</code> reads the
   <code class="literal">master</code> key from the file
   <var class="filename">database.ini</var> placed in the
   <var class="filename">users/</var> sub-directory.
  </p>
  <p class="simpara">
   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 <var class="filename">.ini</var> files can
   instead be placed in a directory readable only by root, such as
   <var class="filename">/etc/yaconf</var>: 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.
  </p>
  <p class="simpara">
   Yaconf requires PHP 7.0 or greater.
  </p>
 </div>

 






 







<ul class="chunklist chunklist_book"><li><a href="yaconf.setup.php">Installing/Configuring</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="yaconf.requirements.php">Requirements</a></li><li><a href="yaconf.installation.php">Installation</a></li><li><a href="yaconf.configuration.php">Runtime Configuration</a></li><li><a href="yaconf.resources.php">Resource Types</a></li></ul></li><li><a href="class.yaconf.php">Yaconf</a> — The Yaconf class<ul class="chunklist chunklist_book chunklist_children"><li><a href="yaconf.debug-info.php">Yaconf::__debug_info</a> — Inspect how a configuration value is stored</li><li><a href="yaconf.get.php">Yaconf::get</a> — Retrieve a configuration value by name</li><li><a href="yaconf.has.php">Yaconf::has</a> — Check whether a configuration value exists</li></ul></li></ul></div><?php manual_footer($setup); ?>