[PROPOSAL] PHP Component Model
| From: | Sebastian Bergmann | Date: | Mon, 15 Sep 2003 16:10:40 +0000 |
| Subject: | [PROPOSAL] PHP Component Model | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-21516@lists.php.net to get a copy of this message | ||
Hi,
I would like to propose a package called PHP_ComponentModel which is the
reference implementation of the PHP Component Model.
The PHP Component Model is to become a standard for the development of
exchangable components that can be customized and plugged together
using PHP Development Environments (PHP IDEs).
Quoting Philippe Krutchen from Rational Software "A component is a
nontrival, nearly independent, and replaceable part of a system that
fulfills a clear function in the context of a well-defined
architecture. A component conforms to and provides the physical
realization of a set of interfaces."
At the core of the PHP Component Model is the Component Container.
The Components register themselves with the Component Container and
communicate among each other by the means of Events. When a component
fires an event the event is first received by the Component Container
which in turn broadcasts the event to all registered components.
A PHP Component is a PHP class that adheres to the coding standards
below. Upon instantiation a PHP Component registers itself
automatically with the Component Container, loads its configuration
and is then ready to respond to events.
The configuration of PHP Components should be done using PHP
Development Environments (PHP IDEs) that have support for the PHP
Component Model Metadata format.
A component class must
* extend the PHP_ComponentModel_Component class,
* provide two protected member arrays, $neededServices and
$providedServices, that contain the names of the services that the
component needs and provides,
* provide two protected member arrays, $incomingEvents and
$outgoingEvents, that contain the class names of the events that
the component fires and handles,
* implement the handleEvent(PHP_ComponentModel_Event $e) method.
A component class may
* implement the two methods start() and stop of the
PHP_ComponentModel_Startable interface,
* implement the checkPropertyChange($propertyName, $value) method to
check if a property change conforms with the property's bounds and
return FALSE if it does not.
A class that follows these coding standards can be used as a PHP
Component because it
* is able to fire and handle events,
* provides the introspection support needed for the Metadata system
* and can thus be customized using PHP Development Environments (PHP
IDEs) that have support for the PHP Component Model.
The PHP_ComponentModel_Container interface describes the functionality
Component Containers need to implement to be used in the PHP Component
model context. The already available DefaultContainer implementation
needs to initialize the components for each request. The yet to be
implemented SRMContainer will run each component in a separate
Banana "thread".
Source:
http://www.sebastian-bergmann.de/PCOM/Component.phps
http://www.sebastian-bergmann.de/PCOM/Container.phps
http://www.sebastian-bergmann.de/PCOM/DefaultContainer.phps
http://www.sebastian-bergmann.de/PCOM/DependencyException.phps
http://www.sebastian-bergmann.de/PCOM/Event.phps
http://www.sebastian-bergmann.de/PCOM/IllegalStateException.phps
http://www.sebastian-bergmann.de/PCOM/Startable.phps
The next development cycle will focus on the Metadata system needed to
customize components using PHP Development Environments (IDEs).
For this purpose methods will be implemented that:
* Generate an XML representation of a PHP Component.
* Generate a PHP source skeleton from an XML representation of a
PHP Component.
* Serialize a PHP Component's customization into an XML
representation.
* Unserialize a PHP Component's customization from the above
mentioned XML representation.
Greetings,
Sebastian
--
Sebastian Bergmann
http://sebastian-bergmann.de/ http://phpOpenTracker.de/
Das Buch zu PHP 5: http://professionelle-softwareentwicklung-mit-php5.de/