2. So, what is FOF anyway?
November 18th, 2012 – Joomla! World Conference
3. I know what you’re thinking
“Oh, no, not yet another framework!”
November 18th, 2012 – Joomla! World Conference
4. FOF extends the Joomla! framework
It does not replace or undermine it
November 18th, 2012 – Joomla! World Conference
5. DRY - Don’t Repeat Yourself
I detest copying and pasting the same code, over and over and over and over and over and over and over...
November 18th, 2012 – Joomla! World Conference
6. Less is more
Convention over configuration – less dev time, less code, less bugs, less maintenance
November 18th, 2012 – Joomla! World Conference
7. Doesn’t impose its way of thinking
No black-box methods, multiple customizable triggers, plugin events, ...
November 18th, 2012 – Joomla! World Conference
10. Some history
How it all came to be
November 18th, 2012 – Joomla! World Conference
11. July 2009 – Base MVC classes
Custom classes, extending JModel and friends, reducing copy & pasted code
November 18th, 2012 – Joomla! World Conference
12. September 2011 – Transformed into a framework
Basically, I was pissed with another framework which kept on screwing me over
November 18th, 2012 – Joomla! World Conference
13. Be the change
you want to see!
September 2011 – Transformed into a framework
Basically, I was pissed with another framework which kept on screwing me over
November 18th, 2012 – Joomla! World Conference
14. September 2012 – HMVC
while stuck on the ground, inside a plane, for four freakin’ hours!
November 18th, 2012 – Joomla! World Conference
15. May 2012 – Public release
at the J and Beyond 2012 conference
November 18th, 2012 – Joomla! World Conference
16. June 2012 – Bootstrap & jQuery
In optional Akeeba Strapper package
November 18th, 2012 – Joomla! World Conference
17. Being a FOF Component
Inside its mind, without visiting the 71/2 floor of a Manhattan office building
November 18th, 2012 – Joomla! World Conference
18. AUDIENCE
ADVISORY
BORING SLIDES
November 18th, 2012 – Joomla! World Conference
19. Structure
Dispatcher
“triad”
Controller
Model View
Table
Helpers Toolbar
20. Structure
Dispatcher
The“triad”
Dispatcher is the entry point (a.k.a. “router”). It will setup,
Controller
run and render the MVC triad.
Model View
Table
Helpers Toolbar
21. Structure
The Controller is a thin interface to push data to the model state
Dispatcher
and instantiate views
“triad”
Controller
Model View
Table
Helpers Toolbar
22. Structure
Dispatcher
“triad”
Controller
Model View
Table
The Model is the workhorse. Business logic goes here.
Helpers Toolbar
23. Structure
Dispatcher
“triad”
Controller
Model View
Table
The Table class is a hybrid data adapter, controller and model
Helpers Toolbar
(following J!'s convention)
24. Structure
Dispatcher
“triad”
Controller
Model View
Table
The View fetches model state data and renders them in a
meaningful way
Helpers Toolbar
25. Structure
Dispatcher
“triad”
Controller
Model View
The Toolbar handles Table rendering of titles, buttons and so on
the
Helpers Toolbar
26. Structure
Dispatcher
“triad”
Controller
Model View
Non-OOP stuff.Table
Basically, a nice way to say “cruft”
Helpers Toolbar
27. Some general thoughts
✤ Almost RESTful, but not quite
✤ “Services first” approach. Built-in JSON and transparent
authentication, opens the door to data provisioning for rich JS,
Android, iOS etc apps
✤ OAuth not supported (yet?). A custom, secure, TOTP-based
transparent authentication scheme and HTTP Basic Authentication
are supported, though.
✤ We offer HMVC today. Actually, since October 2011.
29. Convention over configuration in
the Dispatcher
✤ The Dispatcher is your component’s router. It routes the request to the
appropriate Controller based on conventions:
✤ A POST request gets routed to the save task
✤ A GET request to a plural view name gets routed to the browse
task
✤ A front-end GET request with an ID gets routed to the read task
✤ A back-end GET request with an ID gets routed to the edit task
30. Convention over configuration in
Models
✤ Tables are named as #__component_view, e.g. #__todo_items
✤ Auto increment field is named component_view_id, e.g. todo_item_id
✤ Magic fields: enabled, created_by, created_on, modified_by,
modified_on, locked_by, locked_on, hits
✤ You can override defaults without copying & pasting code, ever.
Copy & paste is the devil!
31. Convention over configuration in
Controllers
✤ Default tasks (not RESTful!): browse, read, edit, add, delete, save,
apply, ...
✤ Customize with onBeforeMethod and onAfterMethod methods, e.g.
onBeforeSave. Don't 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 it's missing based on plural/singular view
name and existence of ID in the query
32. Convention over configuration in
Views
✤ Views inherit from FOFView and its specialized children, e.g.
FOFViewHtml
✤ Customize using the onTask methods, e.g. onBrowse
✤ The toolbar is handled outside the view, in a FOFToolbar descendant
class. Override it with a toolbar.php file in the component's root.
✤ Magic toolbar methods, e.g. onItemsBrowse allow you to customize
the toolbar without copying & pasting code.
34. HMVC – Hierarchical MVC
✤ Include the results of component views anywhere (other views, other
component, modules, ...)
✤ FOFDispatcher::getTmpInstance(‘com_foobar’, ‘items’, array(‘layout’
=> ‘fancy’))->dispatch();
35. Reuse view templates
✤ Load a view template from another view, component, ...
✤ echo $this->loadAnyTemplate('site:com_foobar/item/form');
36. Language loading and overrides
✤ Automatically loads component language files (frontend and
backend)
✤ Hierarchical language overriding
✤ English loads first
✤ Current site/user language loads next and overrides English
37. Media files overrides
✤ Load 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
38. Services first – automatic JSON
and CSV views
✤ Just add format=json or format=csv
✤ JSON: You have an instant JSON-based remote API for your
components
✤ CSV: You can quickly export whatever you see in the backend to
Excel, Numbers, LibreOffice, Google Docs, etc.
✤ Transparent authentication support using URL parameters or HTTP
Basic Authentication
41. Are you pondering what I’m
pondering?
✤ Input as an object, not as an array (yes, static methods suck)
42. Are you pondering what I’m
pondering?
✤ Input as an object, not as an array (yes, static methods suck)
✤ Remove dependence on JModelLegacy and friends
43. Are you pondering what I’m
pondering?
✤ Input as an object, not as an array (yes, static methods suck)
✤ Remove dependence on JModelLegacy and friends
✤ FOFForm: (almost) no PHP and no HTML Joomla! extensions
44. Are you pondering what I’m
pondering?
✤ Input as an object, not as an array (yes, static methods suck)
✤ Remove dependence on JModelLegacy and friends
✤ FOFForm: (almost) no PHP and no HTML Joomla! extensions
✤ Platform abstraction, allow use with JApplicationWeb and friends
45. Are you pondering what I’m
pondering?
✤ Input as an object, not as an array (yes, static methods suck)
✤ Remove dependence on JModelLegacy and friends
✤ FOFForm: (almost) no PHP and no HTML Joomla! extensions
✤ Platform abstraction, allow use with JApplicationWeb and friends
✤ RFC 2324 implementation (client)
46. Are you pondering what I’m
pondering?
✤ Input as an object, not as an array (yes, static methods suck)
✤ Remove dependence on JModelLegacy and friends
✤ FOFForm: (almost) no PHP and no HTML Joomla! extensions
✤ Platform abstraction, allow use with JApplicationWeb and friends
✤ RFC 2324 implementation (client)
✤ A plan to take over the world!