| Vorheriges Thema anzeigen :: Nächstes Thema anzeigen |
| Autor |
Nachricht |
plugged Neuer User
Anmeldungsdatum: 20.05.2005 Beiträge: 2
|
20.05.2005 4:45 Suggestions for PEAR based Plugin Class for PHP ? |
|
|
Hi !
... I know this is quite a task, but I would really like to see an advanced plugin architecture for PHP source code, something that allows users to derive their applications from a general plugin class so that modules can be loaded at runtime that access global pointers of the application itself.
Maybe one could start out simple and try to collect suggestions here ? _________________ thx,
plugged |
|
| Nach oben |
|
 |
alexpetri User
Anmeldungsdatum: 24.02.2004 Beiträge: 250 Wohnort: Frankfurt Main
|
20.05.2005 8:23 |
|
|
pls explain that..
i dont understand for what we should do that (what reason)?
please explain that.
note that this is a german forum.
But never mind, if you keep your words easy to understand, you can write in
English. |
|
| Nach oben |
|
 |
plugged Neuer User
Anmeldungsdatum: 20.05.2005 Beiträge: 2
|
22.05.2005 8:34 |
|
|
| alexpetri hat folgendes geschrieben: | pls explain that..
i dont understand for what we should do that (what reason)?
please explain that.
note that this is a german forum.
But never mind, if you keep your words easy to understand, you can write in
English. |
Hi !
Thanks for your reply.
Sorry about the language issue... I just followed the link on the pear webpage (but to be honest: I'm not aware of any English-speaking PEAR forum either ?).
If there's a more appropriate place to discuss this idea, please tell me so !
Well, concerning my last posting: I wasn't meaning to make a feature request for PEAR, rather
I was trying to collect some suggestions and ideas about how one could possibly achieve
the goal of a dynamic plugin architecture for php based (web) applications, mainly because I did already
spend some time thinking about various possibilities, so I'd like to get some feedback.
So, this was not necessarily meant to be specific to PEAR, even though I did indeed feel that
the overall idea itself would not be beyond the scope of PEAR, rather it seemed to fit quite well to the goals of PEAR (as outlined at http://pear.php.net).
But to provide some explanations: the various advantages of a plugin system for many web applications are obvious:
- anybody can contribute to the overall project, no need to be a 'core' developer, no need to even have CVS priviledges, no need to be intimately familiar with the the source code of the entire application, rather one would only need to be familiar with a limited plugin API
- a limited plugin API is much less a task to document WELL
- very specific features can be implemented in a maximally modular fashion
- extensions can be easily shared amongst users
- so, users don't need to manually edit source files of the application itself in order to add a simple feature
etc.
For example - meanwhile, several big php projects had to come up with mechanisms to allow for support of
external (i.e. community-based) extensions to their applications, not only with regards to "soft extensions" (i.e. templates/styles etc.), but often also with regards to adding functionality/features (logics/code) to the application itself, that would not really fit natively into the application itself or that may simply be too specific to be included with the general release.
While several large CMS applications (i.e. postnuke etc.) have come up with relatively powerful extension mechanisms, these are usually -and understandably- very specific to the underlying application itself, so they cannot easily be generalized (and e.g. be put into a wrapper object for other purposes or applications).
Basically, you'll often see php developers who require dynamic extendability, trying to re-invent their own plugin system for their specific web application.
So, there are actually many big php based projects that would directly benefit from a standardized plugin-architecture for php:
Look at examples like the various php based forum applications (i.e. phpBB): mostly you'll notice that popular projects will have grown a community of people that provide patches to the original code base of an application in order to add certain functions that are not available within the actual application, phpBB is an excellente example for this (they call it the "MOD community".
However, patching the source code of an application is usually not a very elegant approach - in particular when it comes to adding multiple new features (=> patches) things are getting really complicated (dependecies break, etc.).
And as soon as a new version of the actual application is released, users are confronted with the huge problem of having to upgrade a modified source base - which is usually a non-trivial task.
Hence, it would actually be very useful if there was a standardized approach to "plugins" for php based applications, as I said before: I do realize that this quite a challenge, but I would really like to collect some suggestions of other php developers for such a library.
I am envisioning something like a very generic wrapper object that can be used to derive subclasses from it, subclasses for plugins as well as the underlying host application itself.
Basically, each plugin will need to have access to at least one global object that contains helper methods and relevant variables, so that the "client plugin" can access functionality that's available on the host application, and plugins themselves can also register new functionality within the host application.
For example, here's some Pseudo-Code:
| Code: |
/*
* myplugin.php
*
*/
require_once('MyPlugin.inc.php'); //contains host subclass
class myplugin extends MyWebAppPlugin //MyWebAppPlugin would then be a subclass of the overall Plugin obj
{
//handler functions, automatically executed by host:
function _register($host_obj)
{
//register a new function within the global scope
$host_obj->registerNewFunc("multiply", array $params('a'=>'numerical','b'=>'numerical'));
...
}
function _modifyCodeTable($host_obj)
{
//modify the calltable to tell php to add a call to the new function
$host_obj->addCall("multiply" ...);
}
//our exported functions:
function multiply($a,$b)
{
return ($a*$b);
}
...
}
|
Essentially, one could write small plugin scripts that are loaded from a specific 'modules folder' during initialization of the host script, the host script would call any pre-requisite handlers and register new callbacks within the host object so that plugin functions are made available within the global scope of the script.
So, in the end one would be able to dynamically add external code to the host application without touching any of the source tree's files.
As I said already: I am absolutely aware that this is NOT a simple task, also I do realize that there are a lot of things that need to be taken into consideration (i.e. inter-plugin-dependencies (plugins that require eachother => loading order), versioning of host/plugin library etc.)
However, I am very willing to give this shot - and I don't mind that it may take more than a year to ultimately come up with a really powerful solution, but I would really like to get some feedback from other php developers, some sort of exchange about possibilities, ideas, suggestions and potential pitfalls would be really appreciated.
As of now I really intend to follow the "Keep it simple stupid" approach, so I am going to try to set some achievable milestones, i.e.:
- add new functions
- add new objects
- extend existing functions
- extend existing objects
...
Also, I do realize that it would probably not be very feasible to port existing applications to such a modular architecture without rewriting major portions of the underlying code, however new projects might really benefit from such functionality.
So what do you guys think ?
And again: please tell me if there's a more appropriate place to discuss this _________________ thx,
plugged |
|
| Nach oben |
|
 |
alexpetri User
Anmeldungsdatum: 24.02.2004 Beiträge: 250 Wohnort: Frankfurt Main
|
23.05.2005 11:33 |
|
|
i guess that is reason why you should use pear...
you can say this is a kind of framework for any application.
this is in agree with your suggestions/thoghts->
many of the PEAR classes (i.e DB or HTML Quickform)
can easily be extended by own plugins/extensions/drivers or whatever.
i guess you would have the ultimate Framework to build anykind of PHPApplic.
but such a FW would never exist.
so PEAR fulfill all my needs. for big and for small projects...
P.S.: look at the Paer.general mailing group |
|
| Nach oben |
|
 |
|
|
|
Zu Deinen Favoriten hinzufügen
|
Du kannst keine Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum nicht antworten. Du kannst deine Beiträge in diesem Forum nicht bearbeiten. Du kannst deine Beiträge in diesem Forum nicht löschen. Du kannst an Umfragen in diesem Forum nicht mitmachen. Du kannst Dateien in diesem Forum nicht posten Du kannst Dateien in diesem Forum nicht herunterladen
|
|