SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict crabby80's Avatar
    Join Date
    May 2007
    Posts
    387
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Framework agnostic components/modules = HOW?

    Hi guys,

    I'm currently doing some research on how best to re-design/re-build one of our systems architecture.

    One of the proposals I would like to come up with, is to separate our core business logic into a library of re-usable, interoperable components/modules which are framework agnostic.

    Ideally I would like to use a commercial framework such as Zend for the application specific stuff (MVC), but, the modules/components shouldn't be tied to Zend in any way.

    I believe designing it this way gives us a lot more flexibility and scalability!

    (How many more buzz words do you think I could fit in)

    My question to you fine people is this;

    Are there any standards or recommended methods when it comes to developing modules/components in this way?? Ideally I would like these to be easy to plug-in into any framework and later down the line I would like to be able to distribute some if these components to other developers.

    The idea sounds great but it sounds like a mammoth task!!

    Any help/guidance would be much much appreciated

    Peace
    Crabby80

  2. #2
    SitePoint Guru bronze trophy TomB's Avatar
    Join Date
    Oct 2005
    Location
    Milton Keynes, UK
    Posts
    989
    Mentioned
    9 Post(s)
    Tagged
    2 Thread(s)
    I'd say this is what you should be striving for anyway for testability.

    You could very easily make all of your models framework independant (If you're using real models, and not the simple DAO kind implemented by most frameworks) but what about framework tools such as ORMs, form processing classes, etc? Are you restricting yourself from those too?

    Michael Morris has posted quite a bit about moving all the business logic to the database via stored procedures, views, etc. Although the technical aspects are different, the separation of concerns is identical.

  3. #3
    SitePoint Evangelist
    Join Date
    Aug 2005
    Location
    Winnipeg
    Posts
    498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are there any standards or recommended methods when it comes to developing modules/components in this way?? Ideally I would like these to be easy to plug-in into any framework and later down the line I would like to be able to distribute some if these components to other developers.
    No, not that I am aware of anyway. There are some problems which would need to be addressed.

    WordPress has a wildly different architecture from drupal. Joomla is also significantly different from both of those. In order to "share" modules or components between these distinct systems would be no trivial task.

    First off, many of these systems provide a library of code for generating forms, validating data, building interfaces (menus/lists/etc). To complicate matters they are often tightly coupled to the specific architecture.

    Now if you wanted to use a "framework" (in the truest sense of the word) such as Zend you would be limited i what you could reuse. Joomla may allow you to swap it's controllers with a Zend controller class but it would have to implement the same interface as the Joomla controllers; think adapter pattern.

    Drupal and WordPress do not really have a distinct controller architecture but instead consist of a series of modules which are implemented as hooks that get invoked at various points of execution.

    Modules are (in Drupal) a folder with specific files in it. The module code itself is implemented as standard functions so using Zend controller is out of the question.

    There would be no re-use of the front controller architecture in any of the above as each already provides it's own implementation or something very similar.

    The best you could realistically achieve, is using Zend/CodeIgnitor as a library for sending mail, or working with RESTful service or LDAP, etc.

    Drupal for instance, offers it's own FORM API - which if you overrode with Zend would probably cause mass confusion amongst people who download your module and try and manipulate it using the Drupal builtin FORM API.

    While it's technically possible the practical side of me don't even bother. If you are seeing a business market in writing a components/module once and having it run in Drupal, Joomla and WordPress, you are in for a big challenge.

    The most practical approach to solving this would be to follow GTK+ or similar corss-platform framework that can compile and run under Linux, Mac and Windows. Having a component run under WordPress, Joomla or Drupal is very much the same at least at first glance.

    Joomla is far more adherent to MVC design pattern than say Drupal/WordPress so bridging that gap would prove very difficult I'm sure.

    You would have an easier time making a module cross-platform in WordPress or Drupal because of their similar architecture.

    Cheers,
    Alex
    The only constant in software is change itself

  4. #4
    SitePoint Guru bronze trophy TomB's Avatar
    Join Date
    Oct 2005
    Location
    Milton Keynes, UK
    Posts
    989
    Mentioned
    9 Post(s)
    Tagged
    2 Thread(s)
    I would not use Wordpress or Joomla as examples of well thought out architectures. Frankly, the code for both is a mess.

    I can't comment on Drupal though.

  5. #5
    SitePoint Addict crabby80's Avatar
    Join Date
    May 2007
    Posts
    387
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your replies guys,

    Check this out Stuart Herbert On PHP - Series: Beyond Frameworks – PHP Components

    Great articles, I saw this guy at the London PHP conference 2011, his talk inspired me to investigate his approach.

    I think this method makes perfect sense, it's just learning and understanding how to implement it in our architecture

  6. #6
    SitePoint Evangelist
    Join Date
    Aug 2005
    Location
    Winnipeg
    Posts
    498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would not use Wordpress or Joomla as examples of well thought out architectures. Frankly, the code for both is a mess.

    I can't comment on Drupal though.
    Ignoring code, the architecture of Joomla is MVC based. Drupal and WordPress use a hook/callback architecture which allows for interesting extension but sloppy full stack solutions. In Joomla you download CRM solutions, Drupal you build something more custom by pulling togather various existing modules and configuring them accordingly.

    The code for WP or Drupal architecturally is less than ideal, there are a lot of cross cutting concerns, as there are in Joomla, but Drupal code is consistent and clean which is why I think so many people think it's superior.

    Cheers,
    Alex
    The only constant in software is change itself


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •