An introduction to Symfony 2 for symfony 1 developers
Upcoming SlideShare
Loading in...5

An introduction to Symfony 2 for symfony 1 developers






Total Views
Views on SlideShare
Embed Views



1 Embed 5 5



Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

An introduction to Symfony 2 for symfony 1 developers An introduction to Symfony 2 for symfony 1 developers Presentation Transcript

  • An introduction to symfony 2 for symfony 1 developers By Giorgio Cefaro
  • What is Symfony 1? Symfony is a full-stack framework, a library of cohesive classes written in PHP. It provides an architecture, components and tools for developers to build complex web applications faster. from
  • What is 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.” “ I don't like MVC because that's not how the web works. Symfony2 is an HTTP framework; it is a Request/Response framework. That's the big deal. The fundamental principles of Symfony2 are centered around the HTTP specification.” from F. Potencier blog
  • Directory structure
    • Symfony 1.4
    • Symfony 2
  • General architectural differences
    • Symfony 1.4
      • Full stack MVC framework
      • Complex controller layer
      • Multi-application architecture
      • Application/plugin level routing
      • Code organized in applications/modules and plugins
    • Symfony 2
      • Full stack MVC decoupled components bundled in a framework, fully HTTP compliant
      • Simpler Controller objects
      • Single application
      • Global routing
      • Code organized in bundles
      • A bundle is like a symfony 1 plugin
      • Even Symfony 2 core components are distributed as bundles
  • Controller
    • Symfony 1
      • Complex and coupled Controller Layer
      • Not fully replaceable (ok, let's say heavy hacking needed!)
      • “ Distributed” over applications, plugins, modules, filters...
      • Dirty mix of routing patterns and straight module access
    • Symfony 2
      • A controller can be easy as a simple PHP function
      • A base Controller class is supplied with several helper methods and can be used as standalone component
      • No routing, no party! Access to controller actions inside bundles MUST go through routing pattern matching
  • Configuration
    • Symfony 1.4
      • Configuration Cascade
      • Lots of yml files (app, factories, database, security, cache, etc ) distributed through apps, plugins and modules
      • You can get easily lost in a complex situation
    • Symfony 2
      • Configuration files inside blundles must be included manually from outside
      • Less configuration files
      • The sole config.yml is incredibly powerful
      • With config.yml and routing.yml you can do almost everything :-)
  • Handling Dependencies
    • Symfony 1.4
      • Dependency handling is left to the developer
      • Service configuration limited to standard components
      • All mixed up in factories.yml
      • Non standard services if not properly handled may easily introduce coupling and poor testability
    • Symfony 2
      • Service Container
      • Dependency Injection for full decoupling and high testability
      • Public and private services, tags, aliases
  • Handling Dependencies – mailer example
    • Symfony 1.4
    • Symfony 2
  • Validation
    • Symfony 1.4
      • Embedded inside forms
      • Validators are not easily reusable in other contexts (for example webservices)
    • Symfony 2
      • Validators are sticked to Entities
      • Configurable via Yaml, xml, annotations or PHP
      • Validators are called via the Service Container
  • Validation
    • Symfony 1.4
    • Symfony 2
  • Persistence - Doctrine
    • Symfony 1.4
      • Bundled with the framework as a standard (with Propel as an alternative)
      • Active Record
      • Design requires lot of effort to make code fully testable
    • Symfony 2
      • Totally decoupled from the framework via Service Container
      • Entities are independent from OR[D]M
      • Entities are mapped to DB via metadata definition (Yaml, xml, or annotations)
  • Persistence - Doctrine
    • Symfony 1.4
    • Symfony 2
  • Persistence - Doctrine
    • Symfony 1
    • Symfony 2
  • Cache
    • Symfony 1.4
      • Non-standard cache mechanism, though flexible and configurable
    • Symfony 2
      • Standard RFC 2616 HTTP Cache
  • Testing
    • Symfony 1.4
      • Lime framework bundled as a standard, PHPUnit can be used as a plugin
      • Lime is not as powerful as PHPUnit
    • Symfony 2
      • Fully integrated with PHPUnit framework
      • In functional tests internal objects can be fully inspected (kernel and DI container too!)
  • Should I move to Symfony 2? Yes.
  • Giorgio Cefaro Twitter: @giorrrgio