REALLY RAPID ADMINAPPLICATION DEVELOPMENT
~WHOAMI• Jose   Diaz-Gonzalez• Resident   IRC Troll (savant)• Rants   at http://josediazgonzalez.com                      ...
WHO IS THIS TALK FOR?• Anyone   building CMS’ for a living• Those   needing quick, extensible CRUD applications• Anyone   ...
WHAT THE HELL IS THIS?• var    $scaffold = true;• ../cake/console/cake    bake• cake   bake skeletons• admin   generation
SCAFFOLD
SCAFFOLDING• Generic   application auto-generation• InCakePHP, introspects the Model::schema() and relationships to pull i...
var $scaffold<?phpclass
IssuesController
extends
AppController
{
   var
$scaffold;}
EXTENDING THIS?• Introspects   model; add callbacks/validation rules/behaviors• _*Scaffold()        Callbacks• Custom     ...
FIN
SCAFFOLD DRAWBACKS• Little   to no usage documentation• Hard     to customize• Easier   to add generic methods in AppContr...
GENERIC METHODS
GENERIC METHODS• Create      index()/view()/add()/edit()/delete() methods in your AppController• Have   callbacks to disab...
/**          
*
Handles
index
requests.          
*          
*
@return
void          
*
@access
public          
*/      ...
class
PostsController
extends
AppController
{



protected
$disabledActions
=
array(index,
add,
edit,
changelog);



publi...
CAVEATS• Has   to be generic enough to use across controllers• Only   portable if built as a plugin library (ie. LazyModel...
BAKE
CAKE BAKE• You   can now view the generated code and modify at will• Have   to re-bake constantly• Everyone   uses it; No ...
BAD CAKE BAKE• Lets   use Model::scaffold = ‐1 please• Generated    view() can result in an empty page• Generated    delet...
EXTENDING THIS?• Templates: app/vendors/shells/templates• Models   are simple to access in templates• Do   you follow “con...
CAKE SKELETONS• ../cake/console/cake   bake project• Multiple   skeletons available• Application   Bootstrap• More   or le...
CAKE SKELETONS• Can’t   use in existing applications• Assume    you’ll always follow the same conventions• Hard    to upgr...
EXTENDING THIS?• Copy     cake/console/templates/skel to app/ vendors/templates/skeletor• Add   plugins, create migrations...
EXISTING CAKE BAKE                 SKELETONS• Andy    Dawson’s Skel• Jon   Bradley’s cake-skel• Dean    Soffer’s BakingPla...
IS THAT ALL?
RAILS GENERATORS
• Generators     generate generators• Scaffolding   similar to bake• Heavy   community use• http://railswizard.org/       ...
RAILS ADMIN
• Port   of MerbAdmin• Ruby   DSL Configuration• Similar   to var $scaffold• Works  with existing applications• Actively   ...
SYMFONY ADMIN
PROGRESSIVE ENHANCEMENT• var   $scaffold on crack• supports   custom fields• weird   templating language• Symfony    win?  ...
YAML YAML YAML
NO GENERATION STEP      save and go
DJANGO ADMIN
DJANGO PONY• Very   customizable• Lots   of available plugins• Lots   of “themes”• Official   Support
CAKE ADMIN
WHY• Need    custom admin interface on top of phpmyadmin• Can’t   use Croogo/Infinitas/etc.• Need    to replicate similar a...
THE GOOD
CLASS BASED//
Access
via
/admin/postsclass
PostCakeAdmin
extends
CakeAdmin
{}
PHP-BASED CONFIGURATION    class
CategoryCakeAdmin
extends
CakeAdmin
{    /**    
*
Where
do
I
“scaffold”
this?    
*    
...
LOOKS EFFIN AMAZING
BETTER BASE METHODSpublic
function
delete($id
=
null)
{



if
(!empty($this‐>data[Category][id]))
{







if
($this‐>Cate...
THE BAD
NO TESTS
HIGH LEARNING CURVE
AND THE REST
CREATING NEW ACTIONS• Needs     an *ActionConfig class• Templates    for Controller/View - Model optional• Similar   to Cak...
WHATS IN AN ACTION       <?php       class
CakeAdminIndexConfig
extends
CakeAdminActionConfig
{       



//
Guess       
...
CAKE ADMIN GENERATE
TODO• More   actions (galleries, TreeBehavior)• Ajax   and other UI enhancements• Web    interface for customization• Scaf...
LINKS•   CakeAdmin: http://github.com/josegonzalez/cake_admin•   Baking Master Class: http://www.neilcrookes.com/2009/07/1...
Really Rapid Admin Application Development
Upcoming SlideShare
Loading in …5
×

Really Rapid Admin Application Development

4,069 views

Published on

How many ways can you generate a CakePHP Admin interface? A summary of the available methods, as well as an intro to CakeAdmin, a class-based admin generation tool.

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

No Downloads
Views
Total views
4,069
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
49
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Really Rapid Admin Application Development

    1. 1. REALLY RAPID ADMINAPPLICATION DEVELOPMENT
    2. 2. ~WHOAMI• Jose Diaz-Gonzalez• Resident IRC Troll (savant)• Rants at http://josediazgonzalez.com ➘• Harasses as @savant me• Codes as josegonzalez on github• Works at @seatgeek not me ➘
    3. 3. WHO IS THIS TALK FOR?• Anyone building CMS’ for a living• Those needing quick, extensible CRUD applications• Anyone looking for a boring challenge
    4. 4. WHAT THE HELL IS THIS?• var $scaffold = true;• ../cake/console/cake bake• cake bake skeletons• admin generation
    5. 5. SCAFFOLD
    6. 6. SCAFFOLDING• Generic application auto-generation• InCakePHP, introspects the Model::schema() and relationships to pull in data• Dumb, never recommended for production, not easy to manipulate
    7. 7. var $scaffold<?phpclass
IssuesController
extends
AppController
{
 var
$scaffold;}
    8. 8. EXTENDING THIS?• Introspects model; add callbacks/validation rules/behaviors• _*Scaffold() Callbacks• Custom app/controller/scaffold.php class• Customize app/views/scaffolds/* views• 2.0 gets cooler scaffold
    9. 9. FIN
    10. 10. SCAFFOLD DRAWBACKS• Little to no usage documentation• Hard to customize• Easier to add generic methods in AppController
    11. 11. GENERIC METHODS
    12. 12. GENERIC METHODS• Create index()/view()/add()/edit()/delete() methods in your AppController• Have callbacks to disable in specific Controllers• Able to override in child Controllers
    13. 13. /** 
*
Handles
index
requests. 
* 
*
@return
void 
*
@access
public 
*/ public
function
index()
{ 



//
Only
do
this
work
if
our
concrete
controller
has
not. 



if
(!isset($this‐>viewVars[Inflector::pluralize($this‐>modelClass)]))
{ 







$this‐>set(array( 











Inflector::pluralize($this‐>modelClass)
=>
$this‐>paginate( 















$this‐>modelClass, 















/** 
















*
Here
we
toss
in
any
conditions
that
were
found
as
named 
















*
parameters
and
which
match
up
to
a
column
in
the
model 
















*
schema. 
















*/ 















array_intersect_key( 



















$this‐>params[named], 



















$this‐>{$this‐>modelClass}‐>schema() 















) 











) 







)); 



} }From https://github.com/joebeeson/crumbs/blob/develop/app_controller.php
    14. 14. class
PostsController
extends
AppController
{



protected
$disabledActions
=
array(index,
add,
edit,
changelog);



public
function
beforeFilter()
{







if
(in_array($this‐>params[action],
$this‐>disabledActions))
{











$this‐>cakeError(404);







}



}} disabling mocked methods
    15. 15. CAVEATS• Has to be generic enough to use across controllers• Only portable if built as a plugin library (ie. LazyModel)• Must remember to build disabling code
    16. 16. BAKE
    17. 17. CAKE BAKE• You can now view the generated code and modify at will• Have to re-bake constantly• Everyone uses it; No one customizes it• Same issues as Scaffold• NOT === var $scaffold
    18. 18. BAD CAKE BAKE• Lets use Model::scaffold = ‐1 please• Generated view() can result in an empty page• Generated delete() lets crawlers potentially auto-delete site• Model::read() usage is evil• Asks too many questions; Can’t I just answer once and rebake?
    19. 19. EXTENDING THIS?• Templates: app/vendors/shells/templates• Models are simple to access in templates• Do you follow “conventions” or allow configuration?• May need custom shell for extra configuration
    20. 20. CAKE SKELETONS• ../cake/console/cake bake project• Multiple skeletons available• Application Bootstrap• More or less portable
    21. 21. CAKE SKELETONS• Can’t use in existing applications• Assume you’ll always follow the same conventions• Hard to upgrade bootstrapped apps in automated fashion• Good for “chop-shops” and freelancers on new apps
    22. 22. EXTENDING THIS?• Copy cake/console/templates/skel to app/ vendors/templates/skeletor• Add plugins, create migrations/schema files• Generate generic models/controllers/views• Customize the HTML/CSS• GITHUB
    23. 23. EXISTING CAKE BAKE SKELETONS• Andy Dawson’s Skel• Jon Bradley’s cake-skel• Dean Soffer’s BakingPlate• Jose Gonzalez’s AppSkellington
    24. 24. IS THAT ALL?
    25. 25. RAILS GENERATORS
    26. 26. • Generators generate generators• Scaffolding similar to bake• Heavy community use• http://railswizard.org/ ^ Someone make this for CakePHP ^ ESSENTIALLY CAKE BAKE+SKELETONS
    27. 27. RAILS ADMIN
    28. 28. • Port of MerbAdmin• Ruby DSL Configuration• Similar to var $scaffold• Works with existing applications• Actively Developed, https://github.com/sferik/rails_admin Unofficial
    29. 29. SYMFONY ADMIN
    30. 30. PROGRESSIVE ENHANCEMENT• var $scaffold on crack• supports custom fields• weird templating language• Symfony win? http://chetzit.com/uploads/images/00/00/04/2010/09/10/4ef9840c2e.png
    31. 31. YAML YAML YAML
    32. 32. NO GENERATION STEP save and go
    33. 33. DJANGO ADMIN
    34. 34. DJANGO PONY• Very customizable• Lots of available plugins• Lots of “themes”• Official Support
    35. 35. CAKE ADMIN
    36. 36. WHY• Need custom admin interface on top of phpmyadmin• Can’t use Croogo/Infinitas/etc.• Need to replicate similar admin interfaces across projects• Let less technical developers create their own interfaces
    37. 37. THE GOOD
    38. 38. CLASS BASED//
Access
via
/admin/postsclass
PostCakeAdmin
extends
CakeAdmin
{}
    39. 39. PHP-BASED CONFIGURATION class
CategoryCakeAdmin
extends
CakeAdmin
{ /** 
*
Where
do
I
“scaffold”
this? 
* 
*
@var
string 
*/ 



public
$plugin








=
dashboard; }
    40. 40. LOOKS EFFIN AMAZING
    41. 41. BETTER BASE METHODSpublic
function
delete($id
=
null)
{



if
(!empty($this‐>data[Category][id]))
{







if
($this‐>Category‐>delete($this‐>data[Category][id]))
{











$this‐>Session‐>setFlash(__d(admin,
Category
deleted,
true),
flash/success);











$this‐>redirect(array(action
=>
index));







}







$this‐>Session‐>setFlash(__d(admin,
Category
was
not
deleted,
true),
flash/error);







$id
=
$this‐>data[Category][id];



}



$this‐>data
=
$this‐>Category‐>find(delete,
compact(id));



if
(!$this‐>data)
{







$this‐>Session‐>setFlash(__d(admin,
Category
unspecified,
true),
flash/error);







$this‐>redirect(array(action
=>
index));



}}
    42. 42. THE BAD
    43. 43. NO TESTS
    44. 44. HIGH LEARNING CURVE
    45. 45. AND THE REST
    46. 46. CREATING NEW ACTIONS• Needs an *ActionConfig class• Templates for Controller/View - Model optional• Similar to Cake Bake Templates• Access to a model and the Admin class config
    47. 47. WHATS IN AN ACTION <?php class
CakeAdminIndexConfig
extends
CakeAdminActionConfig
{ 



//
Guess 



var
$defaults
=
array(
/*
some
options
*/); 



//
Should
we
enable
this
by
default 



var
$enabled
=
true; 



//
Plugin
where
the
templates
for
this
action
are
located 



var
$plugin
=
cake_admin; 



//
Action
type 



var
$type
=
index; 



//
How
do
we
"link"
to
this
method 



var
$linkable
=
List
{{modelname}}; 



//
Custom
model
methods
(find,
related) 



var
$methods
=
array(find); 



//
How
do
we
merge
our
defaults
and
configuration? 



function
mergeVars($admin,
$configuration
=
array())
{ 



} }
    48. 48. CAKE ADMIN GENERATE
    49. 49. TODO• More actions (galleries, TreeBehavior)• Ajax and other UI enhancements• Web interface for customization• Scaffold-like interface in 2.0
    50. 50. LINKS• CakeAdmin: http://github.com/josegonzalez/cake_admin• Baking Master Class: http://www.neilcrookes.com/2009/07/11/baking-master-class-cakefest-jul-09/• AppSkellington: http://github.com/josegonzalez/app_skellington• Skel: http://github.com/ad7six/skel• Cake-Skel: https://github.com/jonbradley/cake-skel• BakingPlate: http://github.com/proloser/bakingplate• RailsAdmin: http://github.com/sferik/rails_admin• DjangoAdmin: https://docs.djangoproject.com/en/1.3/ref/contrib/admin/

    ×