Pyrus's configuration API

Introduction

This documentation describes how to use Pyrus's public class API to access configuration values. Before reading further, you should be familiar with the documentation on Pyrus's configuration.

Pyrus's configuration is controlled by the PEAR2\Pyrus\Config class, which is implemented as a multiton mapping Pyrus installation location to a configuration object. In addition, the current configuration (most recently instantiated) is also accessible to create configuration-agnostic functionality.

Configuration variables are accessed by referring to them as class properties. Here is an example requesting the doc_dir configuration variable, and setting the test_dir configuration variable:

<?php
$docdir 
PEAR2\Pyrus\Config::current()->doc_dir;
PEAR2\Pyrus\Config::current()->test_dir '/path/to/tests';
?>

The user configuration in use is also accessible from each configuration in the same manner as the installation-specific configuration. Here is an example requesting preferred_state and setting verbose:

<?php
$pref 
PEAR2\Pyrus\Config::current()->preferred_state;
PEAR2\Pyrus\Config::current()->verbose 3;
?>

Special variables available

In addition to the configuration variables, Pyrus also defines a few other values that are available, and cannot be used as the names of custom configuration variables:

  • path - the complete PATH_SEPARATOR separated list of cascading directories this configuration represents.

  • location - the writable pyrus installation this configuration represents

  • registry - the registry corresponding to the configuration

  • pluginregistry - the registry corresponding to the location that plugins are installed

  • channelregistry - the channel registry corresponding to the configuration

  • systemvars - an array of names of system configuration variables, built-in and custom

  • uservars - an array of names of user configuration variables, built-in and custom

  • channelvars - an array of channel-specific configuration variables, built-in and custom

  • mainsystemvars - an array of names of built-in system variables

  • mainuservars - an array of names of built-in user variables

  • mainchannelvars - an array of names of built-in channel-specific variables

  • userfile - path to the user configuration file in use by this configuration.

  • customsystemvars - an array of names of custom system variables

  • customuservars - an array of names of custom user variables

  • customchannelvars - an array of names of custom channel-specific variables

Accessing package.xml properties with Pyrus (Previous) Leveraging Pyrus's installation API (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.