$Date$
This example introduce the main facility to export a full configuration layer of an application. You may choice destination and format of data (see PEAR::Config for containers list and options).
[Top]
$registry = &Registry::singleton(); $app = 'sw4p'; $registry->registerApplication($app); $imp = $registry->importConfig($app, 'data/user1.php'); $name = 'data/user2.php'; $exp = $registry->exportConfig($app, [$name = null, [$type = 'phpArray', [$options = array(), [$layer = 'user']]]] );
[Top]
string $app The source application string $name (optional) Name of resource to write to string $type (optional) Type of data source (phpArray, Ini, XML, ...) array $options (optional) Options for the parser string $layer (optional) Config layer to read data from
[Top]
<?php
/**
* Example C4 for Config_Registry : export Config
*
* @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>Export configuration data to an external source </h1>";
$registry =& Config_Registry::singleton();
$app = 'sw4p';
$reg = $registry->registerApplication($app, 'Setup Wizard for PHP', realpath('.'));
handleError($reg);
$data2 = 'data/user1.php';
$type = 'phpArray';
$layer = 'user';
$imp = $registry->importConfig($app, $data2);
handleError($imp);
print "<h2>try 1</h2>";
$data2 = 'data/user2.php';
$type = 'phpArray';
$exp = $registry->exportConfig($app, $data2);
handleError($exp);
echo '<font color="blue"><b>'.$type.' results are in file "'.$data2.'"<br/></b></font>';
print "<h2>try 2</h2>";
$data2 = 'data/user2.ini';
$type = 'iniFile';
$exp = $registry->exportConfig($app, $data2, $type);
handleError($exp);
echo '<font color="blue"><b>'.$type.' results are in file "'.$data2.'"<br/></b></font>';
print "<h2>try 3</h2>";
$data2 = 'data/user2.xml';
$type = 'XML';
$exp = $registry->exportConfig($app, $data2, $type);
handleError($exp);
echo '<font color="blue"><b>'.$type.' results are in file "'.$data2.'"<br/></b></font>';
print "<h2>try 4</h2>";
$data2 = 'data/user2.conf';
$type = 'GenericConf';
$exp = $registry->exportConfig($app, $data2, $type, array('equals' => ';'));
handleError($exp);
echo '<font color="blue"><b>'.$type.' results are in file "'.$data2.'"<br/></b></font>';
?>
[Top]