You are on page 1of 84

Introduction to

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

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

Wednesday, January 11, 2012

History of Symfony

Wednesday, January 11, 2012

Releases .Symfony 2.0: .0: .2: .symfony 1. 2012 .symfony 1.1: January 2007 November 2008 November 2009 July 2011 Planned for early 2012 Wednesday. January 11.symfony 1.Symfony 2.4: .

Routing.YAML. helpers .One of first PHP frameworks to include a Web Debug Toolbar. Propel. Prado i18n. etc) . and an Admin Generator. January 11. 2012 .Several libraries put together (modified Mojavi.Concepts borrowed from several languages and frameworks .symfony 1.0 released on January 2007 “symfony is a full-stack framework. Wednesday. functional tests. CLI. a library of cohesive classes written in PHP” .

Environments .Web Debug Toolbar .symfony 1.0 Highlights . 2012 .Functional Tests . January 11.YAML cascading configuration .ORM integration: Propel and Doctrine .Template Caching .Documentation .Internationalization .Admin Generator .Awesome Community Wednesday.Plugins .CLI .

2012 .0 Highlights .symfony 1.Web Debug Toolbar Wednesday. January 11.

0 Highlights . January 11.symfony 1. 2012 .Admin Generator Wednesday.

symfony 1. 2012 . January 11.0 Highlights .Command Line Interface Wednesday.

2012 .The API documentation http://www.symfony-project.A Gentle Introduction to symfony .The symfony Reference Book .Documentation .org/doc/1_4/ Wednesday.More with symfony .Practical symfony (jobeet tutorial) .0 Highlights . January 11.symfony 1.

google.symfony-project. France.google. Spain Wednesday.com/group/symfony-es Wiki http://trac.org/ Lots of Blogs Conferences around the world: US.symfony-project. January 11.com/group/symfony-users symfony-devs http://groups. 2012 .org/wiki/ Forums http://forum. Germany.symfony 1.0 Highlights .google.Awesome Community IRC #symfony & #symfony-devs Google Groups symfony-users http://groups.com/group/symfony-devs symfony-es http://groups.

2012 .0 Highlights .Plugins Wednesday.symfony 1. January 11.

January 11. Symfony 2 Same philosophy Rewritten from scratch Wednesday. 2012 .symfony 1 vs.

2012 . January 11. Symfony 2 symfony 1 != Symfony2 Wednesday.symfony 1 vs.

x better forget about it. Wednesday.symfony 1 vs. Symfony 2 If you used symfony 1. 2012 . January 11.

Symfony 2 “First. and cohesive PHP components that solve common web development problems.” http://fabien.potencier.org/article/49/what-is-symfony2 Wednesday. based on these components. decoupled. Then. Symfony2 is also a full-stack web framework. January 11. 2012 . Symfony2 is a reusable set of standalone.

January 11.Symfony 2 21 High Quality Components Wednesday. 2012 .

2012 .Symfony 2 Components • • • • • • • • • • • DependencyInjection EventDispatcher HttpFoundation DomCrawler ClassLoader CssSelector HttpKernel BrowserKit Templating Translation Serializer • • • • • • • • • • • Serializer Validator Security Routing Console Process Config Finder Locale Yaml Form All of them at GitHub: http://github. January 11.com/symfony Wednesday.

January 11. 2012 .html Blog post series about creating a framework based on the Symfony2 Components http://fabien.Symfony 2 Components Components Documentation http://symfony.potencier.org/ Wednesday.com/doc/current/components/index.

Symfony 2 Highlights • Rewritten from scratch for PHP 5. 5 beta releases. XML. January 11. 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 Wednesday. 9 stable releases) • Extensible through the creation of Bundles (replacement for sf1 plugins) • Flexible configuration using YAML.3 • Based on the HTTP specification • Very stable and solid API (12 preview releases. 6 release candidates. 2012 .

XML or Annotations • ESI Caching support out of the box • Assets management with Assetic • Translations • Environments Wednesday. 2012 . January 11.Symfony 2 Highlights • 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.

January 11.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 Wednesday. 2012 .

2012 . January 11.Symfony 2 Highlights .SensioLabs Connect Wednesday.

Bundles Wednesday. January 11.Symfony 2 Highlights . 2012 .

2012 . January 11.Symfony 2 Getting Started http://symfony.com/download Wednesday.

9.9.0. 2012 .zip Wednesday. January 11.tgz or unzip Symfony_Standard_Vendors_2.Symfony 2 Getting Started tar zxf Symfony_Standard_Vendors_2.0.

a default configuration.com/distributions Wednesday. a directory structure.Symfony 2 Getting Started Distributions A Symfony distribution is made up of Symfony2 components. 2012 . January 11. a selection of bundles. http://symfony.

January 11.Symfony 2 Getting Started Symfony Standard Distribution • Directory structure • Default configuration • Bundles ⁃ DoctrineBundle ⁃ JMSSecurityExtraBundle ⁃ SensioDistributionBundle ⁃ SensioFrameworkExtraBundle ⁃ SensioGeneratorBundle ⁃ AsseticBundle http://symfony. 2012 .com/distributions Wednesday.

2012 . January 11.Symfony 2 Getting Started Wednesday.

2012 .Symfony 2 Getting Started Wednesday. January 11.

January 11.Symfony 2 Directory Structure Wednesday. 2012 .

2012 . January 11.Symfony 2 Directory Structure Wednesday.

January 11. 2012 .Symfony 2 Directory Structure Wednesday.

January 11.Symfony 2 Directory Structure Wednesday. 2012 .

yml Wednesday.app/config.Symfony 2 Configuration Files . 2012 . January 11.

January 11. 2012 .ini Wednesday.app/parameters.Symfony 2 Configuration Files .

Symfony 2 Configuration Files . January 11. 2012 .app/config_dev.yml Wednesday.

Browser Request Bootstrap (app.php) Controller Template Response Wednesday. January 11. 2012 .

January 11.Bootstrap (app.php) Wednesday. 2012 .

web/app.Symfony 2 Bootstrap File .php Wednesday. 2012 . January 11.

January 11.Controllers Wednesday. 2012 .

Controllers Wednesday. 2012 . January 11.

January 11.Controllers Wednesday. 2012 .

Controllers Wednesday. 2012 . January 11.

2012 .Templates Wednesday. January 11.

Templating / Twig
Comments: {# comments are not rendered #} {# multi-line comments! {{ var }} #} Output variables: {{ var }} {{ var | upper }} {{ var | raw }} {{ object.property }} {{ true ? ‘yes’ : ‘no’ }} http://twig.sensiolabs.org/
Wednesday, January 11, 2012

Templating / Twig
Blocks: {% set var = ‘hello’ %} {% set foo = var ~ ’ and goodbye’ %} {% if foo is ‘bar’ %} ... {% else %} ... {% endif %}

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

Templating / Twig
Blocks: {% for key, val in list %} {{ loop.index }}. {{ val }} {% else %} No keys. {% endfor %} http://twig.sensiolabs.org/
Wednesday, January 11, 2012

Extends:

Templating / Twig

{% extends "Bundle::layout.html.twig" %} Include: {% include “Bundle:Demo:template.html.twig” %} Render: {% render “Bundle:Demo:action” %} http://twig.sensiolabs.org/
Wednesday, January 11, 2012

Fast and Secure Template Language for PHP .net/weaverryan/being-dangerous-with-twig-symfonylive-paris Twig avanzado . The Flexible.Fabien Potencier http://www.slideshare.net/fabpot/twig-the-flexible-fast-and-securetemplatelanguage-for-php Being Dangerous with Twig . January 11.eguiluz/twig-avanzado-sf2vigo (Spanish) Wednesday.slideshare.Javier Eguiluz http://www.Awesome Twig Presentations Twig. 2012 .Ryan Weaver http://slideshare.net/javier.

2012 .html. January 11.Templating / Twig layout.twig Wednesday.

twig Wednesday.html. January 11.Templating / Twig index. 2012 .

2012 .Templating / Twig index.html.twig Wednesday. January 11.

January 11.Bundles Wednesday. 2012 .

January 11.Bundles Everything in Symfony2 is contained in Bundles Wednesday. 2012 .

2012 .Bundles Even Symfony2 is a collection of Bundles Wednesday. January 11.

Symfony 2 Directory Structure Wednesday. January 11. 2012 .

php Wednesday. 2012 . January 11.Symfony 2 Bundles Registration .app/AppKernel.

Bundles Showcase Wednesday. January 11. 2012 .

2012 .Bundles Showcase Wednesday. January 11.

Bundles Showcase Wednesday. January 11. 2012 .

2012 . January 11.Bundles Showcase Wednesday.

Bundles Showcase Wednesday. January 11. 2012 .

2012 . January 11.Bundles Showcase And many many more! Wednesday.

2012 . January 11.Forms Wednesday.

January 11. 2012 .Forms Definition Wednesday.

2012 .Forms Presentation Wednesday. January 11.

Forms Processing Wednesday. 2012 . January 11.

2012 .Web Debug Toolbar & Profiler Wednesday. January 11.

2012 . January 11.Web Debug Toolbar / Profiler Wednesday.

Generator Commands Demo Wednesday. 2012 . January 11.CLI.

2012 BDD Framework Web Acceptance Testing . January 11.Twig Silex Ecosystem ORM & ODM Deployments Wednesday.

Who uses Symfony2? Wednesday. 2012 . January 11.

2012 .Who uses Symfony2? Wednesday. January 11.

January 11. 2012 .Who uses Symfony2? Wednesday.

2012 . January 11.Who uses Symfony2? Wednesday.

Who uses Symfony2? Wednesday. January 11. 2012 .

Who uses Symfony2? Wednesday. January 11. 2012 .

You? Wednesday. 2012 . January 11.

You should :-) Wednesday. January 11. 2012 .

2012 .Questions? Wednesday. January 11.

Wednesday. 2012 . January 11.

2012 .Thank you! Slides: http://slideshare.com Wednesday. January 11.net/pgodel Twitter: @pgodel IRC Freenode: pgodel E-mail: pablo@servergrove.