HomeBack home

A2
Show list of registered applications

$Date$

 Table of contents

  Introduction

The getApplicationsRegistered function allows to know what is the list of applications already defined.

Of course you can anytime, remove a previous application (see unregisterApplication). But take care, that in such case, you'll lose all registered services and configuration data (all layers: 'user', 'system', 'default').

[Top]

  Synopsis

$registry = &Registry::singleton();

$registry->registerApplication('app1', 'My first application');
$registry->registerApplication('appN', 'My last application');

$apps = $registry->getApplicationsRegistered();

[Top]

  Parameters

None

[Top]

  Output

array(2) {
  [0]=>
  array(2) {
    ["handler"]=>
    string(4) "app1"
    ["name"]=>
    string(20) "My first application"
  }
  [1]=>
  array(2) {
    ["handler"]=>
    string(4) "appN"
    ["name"]=>
    string(19) "My last application"
  }
}

[Top]

  Play example


<?php
/**
 * Example A2 for Config_Registry : List of registered applications
 * 
 * @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>List of registered Applications </h1>";

$registry =& Config_Registry::singleton();

print "<h2>try 1</h2>";
print "<p>Given a null array if none application registered</p>";

$reg = $registry->getApplicationsRegistered();

if (count($reg) == 0) {
    echo '<font color="red"><b>None application registered yet</b></font>';
}

print "<h2>try 2</h2>";
print "<p>After at least one application has registered</p>";

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

$reg = $registry->getApplicationsRegistered();

print "<pre>";
var_dump($reg);
print "</pre>";
?>

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

[Top]