KEMBAR78
JWC - Rapid application development with FOF | KEY
Rapid Application Development
with Framework on Framework (FOF)

November 18th, 2012 – Joomla! World Conference
So, what is FOF anyway?
November 18th, 2012 – Joomla! World Conference
I know what you’re thinking
ā€œOh, no, not yet another framework!ā€

November 18th, 2012 – Joomla! World Conference
FOF extends the Joomla! framework
It does not replace or undermine it

November 18th, 2012 – Joomla! World Conference
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
Less is more
Convention over configuration – less dev time, less code, less bugs, less maintenance

November 18th, 2012 – Joomla! World Conference
Doesn’t impose its way of thinking
No black-box methods, multiple customizable triggers, plugin events, ...

November 18th, 2012 – Joomla! World Conference
Plays along nicely
Compatible with Joomla! 1.5, 1.7, 2.5 and 3.0.

November 18th, 2012 – Joomla! World Conference
Backwards compatible
No sudden, quantum changes from one day to the next

November 18th, 2012 – Joomla! World Conference
Some history
How it all came to be

November 18th, 2012 – Joomla! World Conference
July 2009 – Base MVC classes
Custom classes, extending JModel and friends, reducing copy & pasted code

November 18th, 2012 – Joomla! World Conference
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
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
September 2012 – HMVC
while stuck on the ground, inside a plane, for four freakin’ hours!

November 18th, 2012 – Joomla! World Conference
May 2012 – Public release
at the J and Beyond 2012 conference

November 18th, 2012 – Joomla! World Conference
June 2012 – Bootstrap & jQuery
In optional Akeeba Strapper package

November 18th, 2012 – Joomla! World Conference
Being a FOF Component
Inside its mind, without visiting the 71/2 floor of a Manhattan office building

November 18th, 2012 – Joomla! World Conference
AUDIENCE

ADVISORY
              BORING SLIDES
November 18th, 2012 – Joomla! World Conference
Structure

                         Dispatcher


   ā€œtriadā€
                         Controller



             Model                    View

                 Table




                            Helpers    Toolbar
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
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
Structure

                            Dispatcher


   ā€œtriadā€
                            Controller



             Model                         View

                    Table


   The Model is the workhorse. Business logic goes here.
                               Helpers      Toolbar
Structure

                               Dispatcher


    ā€œtriadā€
                               Controller



              Model                           View

                       Table



  The Table class is a hybrid data adapter, controller and model
                                  Helpers        Toolbar
                     (following J!'s convention)
Structure

                             Dispatcher


   ā€œtriadā€
                             Controller



             Model                         View

                     Table
   The View fetches model state data and renders them in a
                     meaningful way
                                Helpers      Toolbar
Structure

                             Dispatcher


    ā€œtriadā€
                              Controller



              Model                            View

  The Toolbar handles Table rendering of titles, buttons and so on
                      the


                                Helpers          Toolbar
Structure

                          Dispatcher


   ā€œtriadā€
                           Controller



             Model                          View

      Non-OOP stuff.Table
                     Basically, a nice way to say ā€œcruftā€


                              Helpers         Toolbar
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.
Convention over Configuration
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
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!
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
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.
Epic features
HMVC – Hierarchical MVC



✤   Include the results of component views anywhere (other views, other
    component, modules, ...)

✤   FOFDispatcher::getTmpInstance(ā€˜com_foobar’, ā€˜items’, array(ā€˜layout’
    => ā€˜fancy’))->dispatch();
Reuse view templates



✤   Load a view template from another view, component, ...

✤   echo $this->loadAnyTemplate('site:com_foobar/item/form');
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
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
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
A peek in my crystal ball
Are you pondering what I’m
pondering?
Are you pondering what I’m
pondering?

✤   Input as an object, not as an array (yes, static methods suck)
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
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
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
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)
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!
Resources and community
http://akeeba.info/fof
CAN I HAZ SOME CODEZ?
Over and out.

JWC - Rapid application development with FOF

  • 1.
    Rapid Application Development withFramework on Framework (FOF) November 18th, 2012 – Joomla! World Conference
  • 2.
    So, what isFOF anyway? November 18th, 2012 – Joomla! World Conference
  • 3.
    I know whatyou’re thinking ā€œOh, no, not yet another framework!ā€ November 18th, 2012 – Joomla! World Conference
  • 4.
    FOF extends theJoomla! framework It does not replace or undermine it November 18th, 2012 – Joomla! World Conference
  • 5.
    DRY - Don’tRepeat 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 Conventionover configuration – less dev time, less code, less bugs, less maintenance November 18th, 2012 – Joomla! World Conference
  • 7.
    Doesn’t impose itsway of thinking No black-box methods, multiple customizable triggers, plugin events, ... November 18th, 2012 – Joomla! World Conference
  • 8.
    Plays along nicely Compatiblewith Joomla! 1.5, 1.7, 2.5 and 3.0. November 18th, 2012 – Joomla! World Conference
  • 9.
    Backwards compatible No sudden,quantum changes from one day to the next November 18th, 2012 – Joomla! World Conference
  • 10.
    Some history How itall 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 FOFComponent 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 Controlleris 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.
  • 28.
  • 29.
    Convention over configurationin 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 configurationin 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 configurationin 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 configurationin 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.
  • 33.
  • 34.
    HMVC – HierarchicalMVC ✤ 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 andoverrides ✤ 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
  • 39.
    A peek inmy crystal ball
  • 40.
    Are you ponderingwhat I’m pondering?
  • 41.
    Are you ponderingwhat I’m pondering? ✤ Input as an object, not as an array (yes, static methods suck)
  • 42.
    Are you ponderingwhat I’m pondering? ✤ Input as an object, not as an array (yes, static methods suck) ✤ Remove dependence on JModelLegacy and friends
  • 43.
    Are you ponderingwhat 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 ponderingwhat 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 ponderingwhat 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 ponderingwhat 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!
  • 47.
  • 48.
    CAN I HAZSOME CODEZ?
  • 49.