Introduction to Symfony 2

84
Introduction to by Pablo Godel Jan 11 2012 - South Florida PHP Users Group Wednesday, January 11, 2012

description

Brief introduction to Symfony 2 framework

Transcript of Introduction to Symfony 2

Page 1: Introduction to Symfony 2

Introduction to

by Pablo Godel Jan 11 2012 - South Florida PHP Users Group

Wednesday, January 11, 2012

Page 2: Introduction to Symfony 2

Who Am I?

⁃ Born in Argentina, living in the US since 1999⁃ PHP & Symfony developer⁃ Founder of the PHP mailing list in spanish ⁃ Cofounder of ServerGrove Networks⁃ Founded in 2005⁃ provider of web hosting specialized in PHP, Symfony,

ZendFramework among others⁃ Very active open source supporter through code

contributions and usergroups/conference sponsoring

Wednesday, January 11, 2012

Page 3: Introduction to Symfony 2

Wednesday, January 11, 2012

Page 4: Introduction to Symfony 2

History of Symfony

Wednesday, January 11, 2012

Page 5: Introduction to Symfony 2

Releases

- symfony 1.0: January 2007- symfony 1.2: November 2008- symfony 1.4: November 2009

- Symfony 2.0: July 2011- Symfony 2.1: Planned for early 2012

Wednesday, January 11, 2012

Page 6: Introduction to Symfony 2

symfony 1.0

- Several libraries put together (modified Mojavi, Propel, Prado i18n, etc)

- Concepts borrowed from several languages and frameworks- Routing, CLI, functional tests, YAML, helpers

- One of first PHP frameworks to include a Web Debug Toolbar, and an Admin Generator.

“symfony is a full-stack framework, a library of cohesive classes written in PHP”

released on January 2007

Wednesday, January 11, 2012

Page 7: Introduction to Symfony 2

- ORM integration: Propel and Doctrine- YAML cascading configuration- Web Debug Toolbar - Admin Generator- Environments- CLI- Functional Tests- Template Caching- Internationalization- Documentation- Plugins- Awesome Community

symfony 1.0Highlights

Wednesday, January 11, 2012

Page 8: Introduction to Symfony 2

symfony 1.0Highlights - Web Debug Toolbar

Wednesday, January 11, 2012

Page 9: Introduction to Symfony 2

symfony 1.0Highlights - Admin Generator

Wednesday, January 11, 2012

Page 10: Introduction to Symfony 2

symfony 1.0Highlights - Command Line Interface

Wednesday, January 11, 2012

Page 11: Introduction to Symfony 2

- A Gentle Introduction to symfony- Practical symfony (jobeet tutorial)- The symfony Reference Book- More with symfony- The API documentation

symfony 1.0Highlights - Documentation

http://www.symfony-project.org/doc/1_4/

Wednesday, January 11, 2012

Page 12: Introduction to Symfony 2

IRC #symfony & #symfony-devs

Google Groupssymfony-users http://groups.google.com/group/symfony-userssymfony-devs http://groups.google.com/group/symfony-devssymfony-es http://groups.google.com/group/symfony-es

Wiki http://trac.symfony-project.org/wiki/

Forums http://forum.symfony-project.org/

Lots of Blogs

Conferences around the world: US, France, Germany, Spain

symfony 1.0Highlights - Awesome Community

Wednesday, January 11, 2012

Page 13: Introduction to Symfony 2

symfony 1.0Highlights - Plugins

Wednesday, January 11, 2012

Page 14: Introduction to Symfony 2

symfony 1 vs. Symfony 2

Same philosophy

Rewritten from scratch

Wednesday, January 11, 2012

Page 15: Introduction to Symfony 2

symfony 1 vs. Symfony 2

symfony 1 != Symfony2

Wednesday, January 11, 2012

Page 16: Introduction to Symfony 2

If you used symfony 1.x

better forget about it.

symfony 1 vs. Symfony 2

Wednesday, January 11, 2012

Page 17: Introduction to Symfony 2

Symfony 2

“First, Symfony2 is a reusable set of standalone, decoupled, and cohesive PHP components that solve common web

development problems.Then, based on these components, Symfony2 is also a

full-stack web framework.”

http://fabien.potencier.org/article/49/what-is-symfony2

Wednesday, January 11, 2012

Page 18: Introduction to Symfony 2

21 High Quality Components

Symfony 2

Wednesday, January 11, 2012

Page 19: Introduction to Symfony 2

• DependencyInjection• EventDispatcher• HttpFoundation• DomCrawler• ClassLoader• CssSelector• HttpKernel• BrowserKit• Templating• Translation• Serializer

All of them at GitHub: http://github.com/symfony

• Serializer• Validator • Security • Routing • Console • Process • Config • Finder • Locale • Yaml• Form

Symfony 2 Components

Wednesday, January 11, 2012

Page 20: Introduction to Symfony 2

Symfony 2 Components

http://symfony.com/doc/current/components/index.html

http://fabien.potencier.org/

Components Documentation

Blog post series about creating a framework based on the Symfony2 Components

Wednesday, January 11, 2012

Page 21: Introduction to Symfony 2

Highlights

• Rewritten from scratch for PHP 5.3• Based on the HTTP specification• Very stable and solid API (12 preview releases, 5 beta

releases, 6 release candidates, 9 stable releases)• Extensible through the creation of Bundles (replacement for

sf1 plugins)• Flexible configuration using YAML, XML, annotations or

PHP • All configuration is compiled to PHP code and cached• Lots of unit tests• Source code audited by independent security firm thanks to

donations of the Symfony Community

Symfony 2

Wednesday, January 11, 2012

Page 22: Introduction to Symfony 2

• Extensible Configuration with Service Container/Dependency Injection

• Complete redesign of Forms support• Validations• Extensible Security with Authentication/Authorization • Advanced and powerful templating through Twig• Routes configured with YAML, XML or Annotations• ESI Caching support out of the box• Assets management with Assetic• Translations• Environments

Symfony 2Highlights

Wednesday, January 11, 2012

Page 23: Introduction to Symfony 2

Community

• 357 developers contributed to Symfony2• 3000+ pull requests• 969 977 bundles at knpbundles.com• Same very active IRC and mailing lists support channels• Community Gamification through SensioLabs Connect• Symfony2 Ecosystem

Symfony 2

Wednesday, January 11, 2012

Page 24: Introduction to Symfony 2

Highlights - SensioLabs ConnectSymfony 2

Wednesday, January 11, 2012

Page 25: Introduction to Symfony 2

Highlights - BundlesSymfony 2

Wednesday, January 11, 2012

Page 26: Introduction to Symfony 2

Getting StartedSymfony 2

http://symfony.com/download

Wednesday, January 11, 2012

Page 27: Introduction to Symfony 2

Getting StartedSymfony 2

or

tar zxf Symfony_Standard_Vendors_2.0.9.tgz

unzip Symfony_Standard_Vendors_2.0.9.zip

Wednesday, January 11, 2012

Page 28: Introduction to Symfony 2

Getting StartedSymfony 2

Distributions

http://symfony.com/distributions

A Symfony distribution is made up of Symfony2 components, a selection of bundles,

a directory structure, a default configuration.

Wednesday, January 11, 2012

Page 29: Introduction to Symfony 2

Getting StartedSymfony 2

http://symfony.com/distributions

Symfony Standard Distribution

• Directory structure• Default configuration• Bundles⁃ DoctrineBundle⁃ JMSSecurityExtraBundle⁃ SensioDistributionBundle⁃ SensioFrameworkExtraBundle⁃ SensioGeneratorBundle⁃ AsseticBundle

Wednesday, January 11, 2012

Page 30: Introduction to Symfony 2

Getting StartedSymfony 2

Wednesday, January 11, 2012

Page 31: Introduction to Symfony 2

Getting StartedSymfony 2

Wednesday, January 11, 2012

Page 32: Introduction to Symfony 2

Directory StructureSymfony 2

Wednesday, January 11, 2012

Page 33: Introduction to Symfony 2

Symfony 2Directory Structure

Wednesday, January 11, 2012

Page 34: Introduction to Symfony 2

Symfony 2Directory Structure

Wednesday, January 11, 2012

Page 35: Introduction to Symfony 2

Symfony 2Directory Structure

Wednesday, January 11, 2012

Page 36: Introduction to Symfony 2

Configuration Files - app/config.ymlSymfony 2

Wednesday, January 11, 2012

Page 37: Introduction to Symfony 2

Configuration Files - app/parameters.iniSymfony 2

Wednesday, January 11, 2012

Page 38: Introduction to Symfony 2

Configuration Files - app/config_dev.ymlSymfony 2

Wednesday, January 11, 2012

Page 39: Introduction to Symfony 2

Browser

Bootstrap (app.php)

Controller

Template

Response

Request

Wednesday, January 11, 2012

Page 40: Introduction to Symfony 2

Bootstrap (app.php)

Wednesday, January 11, 2012

Page 41: Introduction to Symfony 2

Bootstrap File - web/app.phpSymfony 2

Wednesday, January 11, 2012

Page 42: Introduction to Symfony 2

Controllers

Wednesday, January 11, 2012

Page 43: Introduction to Symfony 2

Controllers

Wednesday, January 11, 2012

Page 44: Introduction to Symfony 2

Controllers

Wednesday, January 11, 2012

Page 45: Introduction to Symfony 2

Controllers

Wednesday, January 11, 2012

Page 46: Introduction to Symfony 2

Templates

Wednesday, January 11, 2012

Page 47: Introduction to Symfony 2

Templating / Twig

{# comments are not rendered #}

{# multi-line comments! {{ var }}#}

Comments:

Output variables:{{ var }}{{ var | upper }}{{ var | raw }}{{ object.property }}{{ true ? ‘yes’ : ‘no’ }}

http://twig.sensiolabs.org/Wednesday, January 11, 2012

Page 48: Introduction to Symfony 2

Templating / Twig

{% set var = ‘hello’ %}{% set foo = var ~ ’ and goodbye’ %}

{% if foo is ‘bar’ %}...

{% else %}...

{% endif %}

Blocks:

http://twig.sensiolabs.org/Wednesday, January 11, 2012

Page 49: Introduction to Symfony 2

Templating / Twig

{% for key, val in list %}

{{ loop.index }}. {{ val }}

{% else %}

No keys.

{% endfor %}

Blocks:

http://twig.sensiolabs.org/Wednesday, January 11, 2012

Page 50: Introduction to Symfony 2

Templating / Twig

http://twig.sensiolabs.org/

{% include “Bundle:Demo:template.html.twig” %}

Include:

Render:

{% render “Bundle:Demo:action” %}

Extends:

{% extends "Bundle::layout.html.twig" %}

Wednesday, January 11, 2012

Page 52: Introduction to Symfony 2

layout.html.twigTemplating / Twig

Wednesday, January 11, 2012

Page 53: Introduction to Symfony 2

index.html.twigTemplating / Twig

Wednesday, January 11, 2012

Page 54: Introduction to Symfony 2

Templating / Twigindex.html.twig

Wednesday, January 11, 2012

Page 55: Introduction to Symfony 2

Bundles

Wednesday, January 11, 2012

Page 56: Introduction to Symfony 2

Bundles

Everything in Symfony2 is contained in Bundles

Wednesday, January 11, 2012

Page 57: Introduction to Symfony 2

Bundles

Even Symfony2 is a collection of Bundles

Wednesday, January 11, 2012

Page 58: Introduction to Symfony 2

Symfony 2Directory Structure

Wednesday, January 11, 2012

Page 59: Introduction to Symfony 2

Bundles Registration - app/AppKernel.phpSymfony 2

Wednesday, January 11, 2012

Page 60: Introduction to Symfony 2

Bundles Showcase

Wednesday, January 11, 2012

Page 61: Introduction to Symfony 2

Bundles Showcase

Wednesday, January 11, 2012

Page 62: Introduction to Symfony 2

Bundles Showcase

Wednesday, January 11, 2012

Page 63: Introduction to Symfony 2

Bundles Showcase

Wednesday, January 11, 2012

Page 64: Introduction to Symfony 2

Bundles Showcase

Wednesday, January 11, 2012

Page 65: Introduction to Symfony 2

And many many more!

Bundles Showcase

Wednesday, January 11, 2012

Page 66: Introduction to Symfony 2

Forms

Wednesday, January 11, 2012

Page 67: Introduction to Symfony 2

FormsDefinition

Wednesday, January 11, 2012

Page 68: Introduction to Symfony 2

FormsPresentation

Wednesday, January 11, 2012

Page 69: Introduction to Symfony 2

FormsProcessing

Wednesday, January 11, 2012

Page 70: Introduction to Symfony 2

Web Debug Toolbar&

Profiler

Wednesday, January 11, 2012

Page 71: Introduction to Symfony 2

Web Debug Toolbar / Profiler

Wednesday, January 11, 2012

Page 72: Introduction to Symfony 2

CLI, Generator CommandsDemo

Wednesday, January 11, 2012

Page 73: Introduction to Symfony 2

Ecosystem

Twig Silex

ORM & ODM

Deployments BDD Framework Web Acceptance Testing

Wednesday, January 11, 2012

Page 74: Introduction to Symfony 2

Who uses Symfony2?

Wednesday, January 11, 2012

Page 75: Introduction to Symfony 2

Who uses Symfony2?

Wednesday, January 11, 2012

Page 76: Introduction to Symfony 2

Who uses Symfony2?

Wednesday, January 11, 2012

Page 77: Introduction to Symfony 2

Who uses Symfony2?

Wednesday, January 11, 2012

Page 78: Introduction to Symfony 2

Who uses Symfony2?

Wednesday, January 11, 2012

Page 79: Introduction to Symfony 2

Who uses Symfony2?

Wednesday, January 11, 2012

Page 80: Introduction to Symfony 2

You?

Wednesday, January 11, 2012

Page 81: Introduction to Symfony 2

You should :-)

Wednesday, January 11, 2012

Page 82: Introduction to Symfony 2

Questions?

Wednesday, January 11, 2012

Page 83: Introduction to Symfony 2

Wednesday, January 11, 2012

Page 84: Introduction to Symfony 2

Thank you!

Slides: http://slideshare.net/pgodel

Twitter: @pgodelIRC Freenode: pgodel

E-mail: [email protected]

Wednesday, January 11, 2012