Web Application Plugins?

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Web Application Plugins?

Post by malcolmboston »

Recently i have been rewriting my ecommerce framework to be more flexible in terms of MySQL expansion and to generally standardise many functions.

As a resell plan, i plan on selling the framework to clients and then offering a plugin / module service similar to what Magento / osCommerce does.

I am just looking for further reading on how this can be achieved at the application level, i envision my app to work in the following way

In the admin area for the ecommerce framework, will be a plugin page, which will grab a list of available plugins via XML from my own server, by clicking on them and paying a fee through paypal / card the plugin will then be downloaded and installed automatically, the issue i have is exactly how automated can i get this, i cant see anyway to not manually add calling code but any thoughts would be excellent as ive had no luck with google.

I dont really want to look into how Magento and osCommerce do it, as in my opinion both solutions are overly complicated.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Web Application Plugins?

Post by alex.barylski »

You have probably not found much on Google due to the vocabulary you are searching. Pluggable or runtime extensible applications are and have been formly studied and have a micro-industry behind them, but much like what design patterns do to the 'eveyday' developer, reading up on Aspect Oriented Programming may or may not leave your eyes burning.

It's probably best you use Joomla or Drupal (preferably the former if you want a better pluggable architeture) for a while ad get a feel for how they do it. It's not easy, there are many ways to implement, each with it's pros and cons. You can manually call hook functions at set spots within your application and while this is easiest to implement you quickly have to add another and another and before you know, there very hooks which are supposed to save you from cross cutting concerns (code which belongs in a distinct independent module or function) become a nightmare to deal with.

A truly pluggable system would allow you to seamnlessly extend any part of an application, without ever touching any code and removing it would not cause any inadvertent side effects. Very difficult to achieve, but some solutions are WAY better than others. AOP frameworks attempt to standardize the nomenclature and provide enough funcitonality you as a developer do not have to worry about the under pinnings, but they come at a big cost especially in PHP. Particuarly, portability and complexity and learning curve. Some are dynamic others actually rewrite your code to include pre/post method hooks (aka: join points) and some go a little further.

By far the easiest way (but least flexible) is t simply invoke your plugins methods as callbacks, which manipulate data structures before or after core processing.

For instance, you might have a locale formatter plugin to rewrite a data structure according to lcoale details of the given user. Converting timestamps to a friendly date. Logging is another good example, for the purpose of profiling, audtin control, etc.

My advice would be to build a list of extensions (at least a dozen) and come back with this list of extensions. You can hash out what kinda of extension your system architecture will require to facilitate these plugins. This is how most pluggable systems are designed, organically as opposed to academically. They are adhoc solutions that grown in time and while they are not perfect they are at least easy to understand.

Cheers,
Alex
Post Reply