Back-end with SonataAdminBundle (and Symfony2, of course...)
-
Upload
andrea-delfino -
Category
Technology
-
view
20.838 -
download
1
description
Transcript of Back-end with SonataAdminBundle (and Symfony2, of course...)
BACK-END WITH
SONATA ADMIN BUNDLEAND SYMFONY2, OF COURSE...
Andrea [email protected]
SYMFONYDAY 2012sabato 6 ottobre 12
SYMFONYDAY 2012
•Developer with 10+ years experience•Either SysAdmin (DevOps ❤)•Actually working for Skuola.net•I love Free Software (free as in freedom)•Knowledge sharing (Web, LUG, ..., PUG)
@ottimohttps://github.com/andreadelfino
PUG Turin: http://torino.grusp.org
sabato 6 ottobre 12
THE PROBLEMTIME
Often we have little time for developing the back-end
SYMFONYDAY 2012sabato 6 ottobre 12
EXPECTATIONSWe're migrating from an CMS with a good back-end
THE PROBLEM
SYMFONYDAY 2012sabato 6 ottobre 12
THE SOLUTION
phpMyAdmin
SYMFONYDAY 2012
Xsabato 6 ottobre 12
ALTERNATIVE
SYMFONYDAY 2012
• Homebrew• Altri Framework• SF2/Doctrine CRUD Generator• AdmingeneratorGeneratorBundle• WhiteOctoberAdminBundle• FooSimpleAdminBundle (one-dev-bundle)
sabato 6 ottobre 12
OR...
SonataAdminBundle
SYMFONYDAY 2012
“Admin is not only about Model; but about providing a consistent and rich user experience for managing data.”
Thomas Rabaix
sabato 6 ottobre 12
SONATA PROJECT
SYMFONYDAY 2012
• Mantainer : Thomas Rabaix (https://github.com/rande)
• Sponsor: Ekino (http://www.ekino.com)
• Obiettivo: e-commerce framework• State: 13 bundles e some libraries
http://sonata-project.org
sabato 6 ottobre 12
FEATURES OVERVIEW
SYMFONYDAY 2012
Dashboard
List•Automatic sort•Link to associated admin (Post => User)•Custom templates•Row Action: edit, create, view, ...•Batch Action•Clever row visualisation: boolean values are
represented with 'check picture'•Filter•Pagination
Edit / Create•Inline edition•Association management (create related model with
+ icon)•Group fields•Sortable option•Modal window to select model (when the list can be
important)•Dynamic form on [one|many]-to-many association
(add new element)
Templating•Base templates (field, list, filter) can be overwritten•Layout templates can be defined into the Service
Container
Others•Nested Admin (ie: /news/post/5/comment/list filter
and create comments only for the post with id=5)•Contextual Breadcrumb•Persistent parameters across an Admin•Side menu option•Translated into 17 languages: CA, DE, EN, ES, FR, HR,
IT, JA, LB, NL, PL, PT_BR, PT_PT, RU, SK, SL and UK•Built to be extended•Explain command line utility
Bundles (on top of)•SonataMediaBundle: a media manager bundle•SonataNewsBundle: a news/blog bundle•SonataPageBundle: a page (CMS like) bundle•SonataUserBundle: integration of FOSUserBundle and
SonataAdminBundle
sabato 6 ottobre 12
ECOSYSTEM
SYMFONYDAY 2012
SonataAdminBundleabstract class Admin
SonataDoctrineORMAdmin SonataDoctrineMongoDBAdmin SonataDoctrinePhpcrAdmin
Symfony FrameworkSymfony Components
SonataCacheBundleSonataBlockBundle
SonataJQueryBundleKnpMenuBundle
Exporter
SonataPageBundleSonataNewsBundleSonataMediaBundleSonataUserBundle
Symfony CMF
sabato 6 ottobre 12
INSTALLATION
SYMFONYDAY 2012
• vi deps && vendors install (branch/2.0 + sf2.0)• composer (master + sf2.1)
sabato 6 ottobre 12
CONFIGURATION
SYMFONYDAY 2012
• autoload.php + AppKernel.php• config.yml + routing.yml
sabato 6 ottobre 12
MAYBE NOT EVERYONE KNOWS THAT...
SYMFONYDAY 2012
In Bundle Standalone src/ Skuola/ UniversitaBundle/ Admin/ VersioniBundle/ Admin/ ...
src/ Skuola/ AdminBundle/ Admin/ UniversitaBundle/ VersioniBundle/ ...
skuola.net/admin admin.skuola.net
sabato 6 ottobre 12
ADMIN CLASS
SYMFONYDAY 2012
Class as a Service
Our Admin class
Admin pool Controller
Service
Dashboardgroup
Entity
sabato 6 ottobre 12
DASHBOARD
SYMFONYDAY 2012
} Group
Twitter Bootstrap ;)Quick actions
Entities
sabato 6 ottobre 12
LIST VIEW
SYMFONYDAY 2012
Filters
Custom fields Actions
Batch actions
Export
sabato 6 ottobre 12
LIST VIEW
SYMFONYDAY 2012sabato 6 ottobre 12
LIST VIEW
SYMFONYDAY 2012
Custom Template
Custom Actions
Admin class
List Mapper
sabato 6 ottobre 12
LIST VIEW
SYMFONYDAY 2012
Filters
Actions Route
sabato 6 ottobre 12
EDIT / CREATE FORM
SYMFONYDAY 2012
Associated Entity
CRUD Actions
Help inline
PropertiesEntity Collection
(ManyToMany withextra fields)
sabato 6 ottobre 12
EDIT / CREATE FORM
SYMFONYDAY 2012
Click to choose association
List ViewModal windows ;)
Opera
sabato 6 ottobre 12
EDIT / CREATE FORM
SYMFONYDAY 2012
Creating a new associated Entity
Create Form
Etichette
sabato 6 ottobre 12
EDIT / CREATE FORM
SYMFONYDAY 2012
Model type
Custom visualization
Help inline
Form Mapper
Collection type
sabato 6 ottobre 12
MAYBE NOT EVERYONE KNOWS THAT...
SYMFONYDAY 2012
Custom field block
Form fields template
sabato 6 ottobre 12
OTHER FEATURES
SYMFONYDAY 2012
•Controller for custom and batch actions•Lifecycle Callbacks•Validation•Advanced Templates customization•Pagination•Sidebar & Menu (via KnpMenuBundle)•Translations (10+ languages, Italian included)•ACL / Security Layer (SonataUserBundle + FOSUserBundle)•CLI Utility (app/console sonata:admin:*)
http://sonata-project.org/bundles/admin/2-0/doc/index.html
sabato 6 ottobre 12
CONCLUSIONI
SYMFONYDAY 2012
•Very powerful and flexible•Active community (>260 fork, >50 contrib)
•Stable release near for sf2.0... but still missing•Documentation is sometimes lacking
•Unstable “master” version (for sf2.1)
Being a Good OSS Contributor - Jeremy Mikola (http://joind.in/talk/view/7216)
sabato 6 ottobre 12
Questions?
SYMFONYDAY 2012sabato 6 ottobre 12
SYMFONYDAY 2012
GrazieSo long, and thanks for all the fish! ;)
@ottimohttps://github.com/andreadelfino
Thanks to Thomas Rabaix (@th0masr) for support and Lineke Kerckhoffs-Willems (@the_linie) for presentation tips.
sabato 6 ottobre 12