Re: [PROPOSAL] PHP Component Model
| From: | Matthias Nothhaft | Date: | Tue, 16 Sep 2003 11:45:20 +0000 |
| Subject: | Re: [PROPOSAL] PHP Component Model | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-21542@lists.php.net to get a copy of this message | ||
Hi Sebastian Bergmann, you wrote:
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). Oh really? Where can I learn/read more about this?Who is working on that standard? I also wanted to make my own standard for using components in my application framework I'm working on. I've already planned some little things, but if there is a nice 'open standard' - why not checking out if it fits to my needs ;-)
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. Sounds not bad, but it would be nice to see how 'event communication'works in the 'PHP Component Model' !? I think programming event driven components in PHP is a very important issue because this is totally different from 'the old style' (without events) and this is not easy to understand if you never worked on a 'desktop application'... Will components still communicate by calling methods directly or by exchanging events/messages? Could you give some examples, please? It is so abstract, I think that's good, but hard to understand...
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. It would also be great to see an example how I can implement this method.
A component class may * implement the two methods start() and stop of theRegards, MatthiasPHP_ComponentModel_Startable interface,* implement the checkPropertyChange($propertyName, $value) method tocheck 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 (PHPIDEs) 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.phpsThe 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