Back-end con SonataAdminBundle (e Symfony2, of course...)

28
BACK-END CON SONATA ADMIN BUNDLE E SYMFONY2, OF COURSE... Andrea Delfino andrea.delfi[email protected] SYMFONYDAY 2012 sabato 6 ottobre 12

description

Una breve introduzione sulla creazione di back-end con SonataAdminBundle e Symfony2. (SymfonyDay Italia 2012 - 5 Ott 2012)

Transcript of Back-end con SonataAdminBundle (e Symfony2, of course...)

Page 1: Back-end con SonataAdminBundle (e Symfony2, of course...)

BACK-END CON

SONATA ADMIN BUNDLEE SYMFONY2, OF COURSE...

Andrea [email protected]

SYMFONYDAY 2012sabato 6 ottobre 12

Page 2: Back-end con SonataAdminBundle (e Symfony2, of course...)

SYMFONYDAY 2012

•Sviluppatore da 10+ anni (web e non)•Anche un pò SysAdmin (DevOps ❤)•Lavoro per Skuola.net (giù a piano terra)•Mi piace il Software Libero•Condivido (Web, LUG, ..., PUG)

@ottimohttps://github.com/andreadelfino

PUG Torino: http://torino.grusp.org

sabato 6 ottobre 12

Page 3: Back-end con SonataAdminBundle (e Symfony2, of course...)

IL PROBLEMATEMPO

Abbiamo poco tempo per sviluppare il back-end

SYMFONYDAY 2012sabato 6 ottobre 12

Page 4: Back-end con SonataAdminBundle (e Symfony2, of course...)

ASPETTATIVEStiamo effettuando una migrazione da un CMS con un

buon back-end

IL PROBLEMA

SYMFONYDAY 2012sabato 6 ottobre 12

Page 5: Back-end con SonataAdminBundle (e Symfony2, of course...)

LA SOLUZIONE

phpMyAdmin

SYMFONYDAY 2012

Xsabato 6 ottobre 12

Page 6: Back-end con SonataAdminBundle (e Symfony2, of course...)

ALTERNATIVE

SYMFONYDAY 2012

• Homebrew• Altri Framework• SF2/Doctrine CRUD Generator• AdmingeneratorGeneratorBundle• WhiteOctoberAdminBundle• FooSimpleAdminBundle (one-dev-bundle)

sabato 6 ottobre 12

Page 7: Back-end con SonataAdminBundle (e Symfony2, of course...)

OPPURE

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

Page 8: Back-end con SonataAdminBundle (e Symfony2, of course...)

SONATA PROJECT

SYMFONYDAY 2012

• Mantainer : Thomas Rabaix (https://github.com/rande)

• Sponsor: Ekino (http://www.ekino.com)

• Obiettivo: e-commerce framework• Stato attuale: 13 bundles e qualche libreria

http://sonata-project.org

sabato 6 ottobre 12

Page 9: Back-end con SonataAdminBundle (e Symfony2, of course...)

CARATTERISTICHE

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

Page 10: Back-end con SonataAdminBundle (e Symfony2, of course...)

ECOSISTEMA

SYMFONYDAY 2012

SonataAdminBundleabstract class Admin

SonataDoctrineORMAdmin SonataDoctrineMongoDBAdmin SonataDoctrinePhpcrAdmin

Symfony FrameworkSymfony Components

SonataCacheBundleSonataBlockBundle

SonataJQueryBundleKnpMenuBundle

Exporter

SonataPageBundleSonataNewsBundleSonataMediaBundleSonataUserBundle

Symfony CMF

sabato 6 ottobre 12

Page 11: Back-end con SonataAdminBundle (e Symfony2, of course...)

INSTALLAZIONE

SYMFONYDAY 2012

• vi deps && vendors install (branch/2.0 + sf2.0)• composer (master + sf2.1)

sabato 6 ottobre 12

Page 12: Back-end con SonataAdminBundle (e Symfony2, of course...)

CONFIGURAZIONE

SYMFONYDAY 2012

• autoload.php + AppKernel.php• config.yml + routing.yml

sabato 6 ottobre 12

Page 13: Back-end con SonataAdminBundle (e Symfony2, of course...)

FORSE NON TUTTI SANNO CHE...

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

Page 14: Back-end con SonataAdminBundle (e Symfony2, of course...)

ADMIN CLASS

SYMFONYDAY 2012

Class as a Service

La nostra Admin class

Admin pool Controller

Service

Dashboardgroup

Entità

sabato 6 ottobre 12

Page 15: Back-end con SonataAdminBundle (e Symfony2, of course...)

DASHBOARD

SYMFONYDAY 2012

} Gruppo

Twitter Bootstrap ;)Azioni rapide

Entità

sabato 6 ottobre 12

Page 16: Back-end con SonataAdminBundle (e Symfony2, of course...)

LIST VIEW

SYMFONYDAY 2012

Filtri

Campi personalizzabili Azioni

Azioni batch

Esportazione

sabato 6 ottobre 12

Page 17: Back-end con SonataAdminBundle (e Symfony2, of course...)

LIST VIEW

SYMFONYDAY 2012sabato 6 ottobre 12

Page 18: Back-end con SonataAdminBundle (e Symfony2, of course...)

LIST VIEW

SYMFONYDAY 2012

Template custom

Azioni

Admin class

List Mapper

sabato 6 ottobre 12

Page 19: Back-end con SonataAdminBundle (e Symfony2, of course...)

LIST VIEW

SYMFONYDAY 2012

Filtri

Rotte azioni

sabato 6 ottobre 12

Page 20: Back-end con SonataAdminBundle (e Symfony2, of course...)

EDIT / CREATE FORM

SYMFONYDAY 2012

Entità relazionata

Azioni CRUD

Help inline

ProprietàCollezione di

entitàrelazionate

sabato 6 ottobre 12

Page 21: Back-end con SonataAdminBundle (e Symfony2, of course...)

EDIT / CREATE FORM

SYMFONYDAY 2012

Click per modificarel’associazione

List ViewModal windows ;)

Opera

sabato 6 ottobre 12

Page 22: Back-end con SonataAdminBundle (e Symfony2, of course...)

EDIT / CREATE FORM

SYMFONYDAY 2012

Creazione una nuova entità da associare

Create Form

Etichette

sabato 6 ottobre 12

Page 23: Back-end con SonataAdminBundle (e Symfony2, of course...)

EDIT / CREATE FORM

SYMFONYDAY 2012

Tipo Model per le entità relazionate

Visualizzazione custom

Help inline

Form Mapper

Tipo Collection

sabato 6 ottobre 12

Page 24: Back-end con SonataAdminBundle (e Symfony2, of course...)

FORSE NON TUTTI SANNO CHE...

SYMFONYDAY 2012

Custom field block

Form fields template

sabato 6 ottobre 12

Page 25: Back-end con SonataAdminBundle (e Symfony2, of course...)

ALTRE CARATTERISTICHE

SYMFONYDAY 2012

•Controller per azioni custom e batch•Lifecycle Callbacks•Validazione•Personalizzazione avanzata dei Templates•Paginazione•Sidebar e Menu (via KnpMenuBundle)•Traduzione (10+ lingue, Italiano incluso)•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

Page 26: Back-end con SonataAdminBundle (e Symfony2, of course...)

CONCLUSIONI

SYMFONYDAY 2012

•Molto potente e flessibile•Comunità attiva (>260 fork, >50 contrib)

•Manca ancora una stable release (anche se vicina per sf2.0)•Documentazione carente

•Versione “master” per sf2.1 non sempre stabile

Being a Good OSS Contributor - Jeremy Mikola (http://joind.in/talk/view/7216)

sabato 6 ottobre 12

Page 27: Back-end con SonataAdminBundle (e Symfony2, of course...)

Domande?

SYMFONYDAY 2012sabato 6 ottobre 12

Page 28: Back-end con SonataAdminBundle (e Symfony2, of course...)

SYMFONYDAY 2012

GrazieSo long, and thanks for all the fish! ;)

@ottimohttps://github.com/andreadelfino

[email protected]

Thanks to Thomas Rabaix (@th0masr) for support and Lineke Kerckhoffs-Willems (@the_linie) for presentation tips.

sabato 6 ottobre 12