View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFDEV:Zend Proposal Zone Template With Tracker}

{zone-data:review-end}August 27, 2006{zone-data}


[Alexander Veremyev (Zend Liaison)|~alexander]

0.1 - 30 June 2006: Initial proposal.
0.2 - 3 July 2007: Revised proposal with 2 new methods.

Zend_Environment provides a singular method for obtaining supplementary information on PHP, PHP Modules and other environmental settings

* [phpInfo()|]

* Gathers output from phpInfo() and stores as an associative array
* Provides per-section and/or per-module information from phpInfo()
* Provides OS information as associative array
* Provides list of currently loaded extensions or tests for existence of specific extension
* Provides a module interface to allow further extensions (e.g. security)

* Zend_Exception

A Zend_Environment instance is created by passing one or more Zend_Environment_Module instances to the constructor. The object then parses each module (according to that module's own interpreter) and builds a profile of 'section/module' information.

Currently it retrieves only php-related information, but will be used in the future to gather runtime information on the Zend Framework itself (versions installed, etc) or any other supplementary info that would assist developers during testing/debugging. It could also be used as a diagnostic during install processes for self-installing applications (e.g. checkModule() for modules/php/etc).

Each module that is passed to the Zend_Environment is iterable and allows further inspection of each of the modules contained. The common object returned from a module query is a Zend_Environment_Info, which will always return the following properties (which are set at the discretion of each module):-

$info->title e.g. Session
$info->description e.g. Sessions should only use cookie-based.... etc...
$info->value e.g. $_SESSION...
$info->warning e.g. array('Your time limit is high');
$info->link e.g.


* Zend_Environment
* Zend_Environment_Exception
* Zend_Environment_Info
* Zend_Environment_Module_Abstract
* Zend_Environment_Module_Core
* Zend_Environment_Module_Os
* Zend_Environment_Module_Extension
* Zend_Environment_Module_Server
* Zend_Environment_Module_Ini
* Zend_Environment_Decorator_Interface
* Zend_Environment_Decorator_Text
* Zend_Environment_Decorator_Html
* Zend_Environment_Decorator_File

* Milestone 1: Create prototype with 'core' modules - Ini, Core, Extension, Os - Currently in progress as of 20th Sep 2006
* Milestone 2: Develop, refine and finalise with feedback from community and Zend
* Milestone 3: Commit to Incubator, include simple demo and use cases [
* Milestone 4: Unit tests exist, work, and are checked into SVN
* Milestone 5: Commit initial documentation
* Milestone 6: Extend modules with Security, Hostinfo (tbc) - Contingent on Security module completed by Ed Finkler
* Milestone 7: Add localised (localized? :) warnings, info and error messages - Depends on Zend_Translate being finalised

// Retrieve required modules
$extensions = new Zend_Environment_Module_Extension();
$security = new Zend_Environment_Module_Os();
$ini = new Zend_Environment_Module_Ini();

// Construct environment
$environment = new Zend_Environment(array($extensions,

// Determine current server environment - useful for Zend_Config
$location = $environment->getHostId(array('live' => array('',
'staging' => '*',
'development' => array('',
echo "Location: {$location}\n";

// Check section exists
if ($environment->exists('security')) {
echo("Can perform security updates\n");

// Check module exists and has valid version
if (!$environment->checkModule('extension', 'gd-2.0.12')) {
throw new exception("I can't run without GD 2.0.12!");

// Test module validity
if (!$environment->isValid('os', 'uid')) {
throw new exception("invalid uid");

// Output environment to browser
echo $environment->toHtml();

// Output environment to a log file

// Export environment as an array

For class skeletons please see [attached file|]