Rapid application development with FOF
-
Upload
nicholas-dionysopoulos -
Category
Technology
-
view
2.483 -
download
1
description
Transcript of Rapid application development with FOF
![Page 1: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/1.jpg)
Framework on Framework - FOFRapid application development for the Joomla! CMS
![Page 2: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/2.jpg)
So, what’s that “FOF” thing?
![Page 3: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/3.jpg)
Yeah, I know what you’re thinking“Oh, dear Lord, not ANOTHER framework!”
![Page 4: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/4.jpg)
FOF uses the Joomla! PlatformIt does not completely replace it
![Page 5: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/5.jpg)
Plays along with the other boysCompatible with Joomla! 2.5, 3.0 and 3.1.
![Page 6: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/6.jpg)
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...
![Page 7: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/7.jpg)
Less is moreConvention over configuration – less time, effort, code and bugs
![Page 8: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/8.jpg)
Flexible, without imposing it’s way of thinkingThere are no black boxes. There are methods, plugin events...
![Page 9: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/9.jpg)
Backwards compatibilityThere are no quantum, undocumented changes overnight
![Page 10: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/10.jpg)
Some historyHow we got here
![Page 11: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/11.jpg)
July 2009 – Base MVC classesMy own classes, extending from JModel & co, minimising copied & pasted code
![Page 12: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/12.jpg)
September 2011 – Turning into a proper frameworkBasically, I wanted a RAD framework which doesn’t change every day
![Page 13: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/13.jpg)
October 2011 – Implemented HMVCwhile I was stuck on a plane, on the ground, for four hours
![Page 14: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/14.jpg)
May 2012 – First public releaseduring the J and Beyond 2012 conference
![Page 15: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/15.jpg)
June 2012 – Bootstrap & jQueryIn the optional Akeeba Strapper package
![Page 16: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/16.jpg)
February 2013 – version 2.0 did NOT go into Joomla! 3.1which is basically something good
![Page 17: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/17.jpg)
March 2013 onwards – Taking off with XML view templatesmaking it a really Rapid Application Development framework
![Page 18: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/18.jpg)
FOF’s Anatomy
![Page 19: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/19.jpg)
Some general thoughts
Web services. Integrated JSON support and transparent authentication, opening the door for data provisioning to apps (web, desktop, mobile,...)
Almost RESTful, not entirely
HMVC components right here, right now, without having to relearn Joomla! component development, i.e. the exact opposite of the proposed Joomla! Framework, whenever that ’s ready.
![Page 20: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/20.jpg)
Structure
Dispatcher
Controller
Model View
ToolbarHelpers
“triad”
Table
The 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 state and instantiate views
The 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 a meaningful way
The Toolbar handles the rendering of titles, buttons and so on
Non-OOP stuff. Basically, a nice way to say “cruft”
![Page 21: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/21.jpg)
Convention over Configuration
![Page 22: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/22.jpg)
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
![Page 23: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/23.jpg)
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!
![Page 24: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/24.jpg)
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
![Page 25: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/25.jpg)
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.
![Page 26: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/26.jpg)
Epic features
![Page 27: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/27.jpg)
HMVC – Hierarchical MVC
Include the results of component views anywhere (other views, other component, modules, ...)
FOFDispatcher::getTmpInstance(‘com_foobar’, ‘items’, array( ‘layout’ => ‘fancy’))->dispatch();
![Page 28: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/28.jpg)
Reuse view templates
Load a view template from another view, component, ...
echo $this->loadAnyTemplate('site:com_foobar/item/form');
![Page 29: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/29.jpg)
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
![Page 30: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/30.jpg)
Web services & 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
![Page 31: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/31.jpg)
XML-based views
It’s JForm on double dose of steroids
Browse, read and edit views from XML templates
You don’t need to write any PHP or HTML, but you can mix traditional PHP-based and XML-based templates, even in the same view
Overridable with Joomla! template overrides
You can write components with virtually no PHP code at all
![Page 32: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/32.jpg)
Resources
http://github.com/akeeba/fof
![Page 33: Rapid application development with FOF](https://reader036.fdocuments.in/reader036/viewer/2022081519/554f609cb4c905bb178b46d9/html5/thumbnails/33.jpg)