HomeBack home

Register an application


 Table of contents


This example will show you the first step of how to use Config_Registry. You need at least to register an application before to manage its configuration values or runs its services.



$registry = &Registry::singleton();

$registry->registerApplication($app, [$name = '', [$fileroot = '.']]);



string    $app          The desired application
string    $name         (optional) The desired application name 
string    $fileroot     (optional) The directory where we can find the application 


  Play example

 * Example A1 for Config_Registry : register Application
 * @version    0.1
 * @author     Laurent Laville <pear@laurent-laville.org>
 * @access     public
 * @package    Config_Registry
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
 * $Id$

require_once 'Config/Registry.php';
require_once '../handleError.php';

print "<h1>register Application </h1>";

$registry =& Config_Registry::singleton();

print "<h2>try 1</h2>";
print "<p>If you try to register an application with wrong values, you've got an error</p>";

$app = 'sw4p';
$reg = $registry->registerApplication('', '', '');

if (PEAR::isError($reg)) {
    echo '<font color="red"><b>'. $reg->getMessage() .'</b></font>';

print "<h2>try 2</h2>";
print "<p>The goog way is here</p>";

$app = 'sw4p';
$reg = $registry->registerApplication($app, 'Setup Wizard for PHP', realpath('.'));

if ($registry->isApplicationRegistered($app)) {
    echo '<font color="blue"><b>Application "'.$app.'" is registered</b></font>';
} else {
    echo '<font color="red"><b>Sorry, application "'.$app.'" is not yet registered</b></font>';

print "<h2>try 3</h2>";
print "<p>If you try to register an already application defined, you've got an error</p>";

$app = 'sw4p';
$reg = $registry->registerApplication($app, '', '');


href:  examples/applications/register.php
Run this script