Rapid application development with FOF

3,084 views

Published on

Rapid application development for the Joomla! CMS using FOF (Framework on Framework), the RAD framework by Akeeba Ltd. Presentation given in Joomla! Day Bosnia and Herzegovina 2013.

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,084
On SlideShare
0
From Embeds
0
Number of Embeds
121
Actions
Shares
0
Downloads
17
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Rapid application development with FOF

  1. 1. Framework on Framework - FOFRapid application development for the Joomla! CMS
  2. 2. So, what’s that “FOF” thing?
  3. 3. Yeah, I know what you’re thinking“Oh, dear Lord, not ANOTHER framework!”
  4. 4. FOF uses the Joomla! PlatformIt does not completely replace it
  5. 5. Plays along with the other boysCompatible with Joomla! 2.5, 3.0 and 3.1.
  6. 6. D.R.Y. - Don’t Repeat YourselfI hate copying/pasting the same code over and over and over and over and over and over and over...
  7. 7. Less is moreConvention over configuration – less time, effort, code and bugs
  8. 8. Flexible, without imposing it’s way of thinkingThere are no black boxes. There are methods, plugin events...
  9. 9. Backwards compatibilityThere are no quantum, undocumented changes overnight
  10. 10. Some historyHow we got here
  11. 11. July 2009 – Base MVC classesMy own classes, extending from JModel & co, minimising copied & pasted code
  12. 12. September 2011 – Turning into a proper frameworkBasically, I wanted a RAD framework which doesn’t change every day
  13. 13. October 2011 – Implemented HMVCwhile I was stuck on a plane, on the ground, for four hours
  14. 14. May 2012 – First public releaseduring the J and Beyond 2012 conference
  15. 15. June 2012 – Bootstrap & jQueryIn the optional Akeeba Strapper package
  16. 16. February 2013 – version 2.0 did NOT go into Joomla! 3.1which is basically something good
  17. 17. March 2013 onwards – Taking off with XML view templatesmaking it a really Rapid Application Development framework
  18. 18. FOF’s Anatomy
  19. 19. Some general thoughtsWeb services. Integrated JSON support and transparentauthentication, opening the door for data provisioning to apps (web,desktop, mobile,...)Almost RESTful, not entirelyHMVC components right here, right now, without having torelearn Joomla! component development, i.e. the exact opposite of theproposed Joomla! Framework, whenever that’s ready.
  20. 20. StructureDispatcherControllerModel ViewToolbarHelpers“triad”TableThe Dispatcher is the entry point (a.k.a. “router”). It will setup,run and render the MVC triad.The Controller is a thin interface to push data to the model stateand instantiate viewsThe Model is the workhorse. Business logic goes here.The Table class is a hybrid data adapter, controller and model(following J!s convention)The View fetches model state data and renders them in ameaningful wayThe Toolbar handles the rendering of titles, buttons and so onNon-OOP stuff. Basically, a nice way to say “cruft”
  21. 21. Convention over Configuration
  22. 22. Convention over configuration inthe DispatcherThe Dispatcher is your component’s router. It routes the request tothe appropriate Controller based on conventions:A POST request gets routed to the save taskA GET request to a plural view name gets routed to the browsetaskA front-end GET request with an ID gets routed to the read taskA back-end GET request with an ID gets routed to the edit task
  23. 23. Convention over configuration inModelsTables are named as #__component_view, e.g. #__todo_itemsAuto increment field is named component_view_id, e.g.todo_item_idMagic fields: enabled, created_by, created_on, modified_by,modified_on, locked_by, locked_on, hitsYou can override defaults without copying & pasting code, ever.Copy & paste is the devil!
  24. 24. Convention over configuration inControllersDefault tasks (not RESTful!): browse, read, edit, add, delete, save,apply, ...Customize with onBeforeMethod and onAfterMethod methods, e.g.onBeforeSave. Dont copy & paste code.All MVC objects can be passed a $config array to customize them. It"flows" from dispatcher to component to model and view.FOF guesses the task if its missing based on plural/singular viewname and existence of ID in the query
  25. 25. Convention over configuration inViewsViews inherit from FOFView and its specialized children, e.g.FOFViewHtmlCustomize using the onTask methods, e.g. onBrowseThe toolbar is handled outside the view, in a FOFToolbar descendantclass. Override it with a toolbar.php file in the components root.Magic toolbar methods, e.g. onItemsBrowse allow you to customizethe toolbar without copying & pasting code.
  26. 26. Epic features
  27. 27. HMVC – Hierarchical MVCInclude the results of component views anywhere (other views, othercomponent, modules, ...)FOFDispatcher::getTmpInstance(‘com_foobar’, ‘items’, array(‘layout’=> ‘fancy’))->dispatch();
  28. 28. Reuse view templatesLoad a view template from another view, component, ...echo $this->loadAnyTemplate(site:com_foobar/item/form);
  29. 29. Media files overridesLoad media files like this:FOFTemplateUtils::addCSS(media://com_foobar/css/frontend.css);Media overrides are inside the template folder, e.g.templates/tpl_example/media/com_foobar/css/frontend.css
  30. 30. Web services & automatic JSONand CSV viewsJust add format=json or format=csvJSON: You have an instant JSON-based remote API for yourcomponentsCSV: You can quickly export whatever you see in the backend toExcel, Numbers, LibreOffice, Google Docs, etc.Transparent authentication support using URL parameters or HTTPBasic Authentication
  31. 31. XML-based viewsIt’s JForm on double dose of steroidsBrowse, read and edit views from XML templatesYou don’t need to write any PHP or HTML, but you can mixtraditional PHP-based and XML-based templates, even in the sameviewOverridable with Joomla! template overridesYou can write components with virtually no PHP code at all
  32. 32. Resourceshttp://github.com/akeeba/fof

×