Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

An introduction to Symfony 2 for symfony 1 developers


Published on

Published in: Technology, Education
  • Follow the link, new dating source: ❶❶❶ ❶❶❶
    Are you sure you want to  Yes  No
    Your message goes here
  • Sex in your area is here: ♥♥♥ ♥♥♥
    Are you sure you want to  Yes  No
    Your message goes here

An introduction to Symfony 2 for symfony 1 developers

  1. 1. An introduction to symfony 2 for symfony 1 developers By Giorgio Cefaro
  2. 2. 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
  3. 3. 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
  4. 4. Directory structure <ul><li>Symfony 1.4 </li></ul><ul><li>Symfony 2 </li></ul>
  5. 5. General architectural differences <ul><li>Symfony 1.4 </li><ul><li>Full stack MVC framework
  6. 6. Complex controller layer
  7. 7. Multi-application architecture
  8. 8. Application/plugin level routing
  9. 9. Code organized in applications/modules and plugins </li></ul></ul><ul><li>Symfony 2 </li><ul><li>Full stack MVC decoupled components bundled in a framework, fully HTTP compliant
  10. 10. Simpler Controller objects
  11. 11. Single application
  12. 12. Global routing
  13. 13. Code organized in bundles
  14. 14. A bundle is like a symfony 1 plugin
  15. 15. Even Symfony 2 core components are distributed as bundles </li></ul></ul>
  16. 16. Controller <ul><li>Symfony 1 </li><ul><li>Complex and coupled Controller Layer
  17. 17. Not fully replaceable (ok, let's say heavy hacking needed!)
  18. 18. “ Distributed” over applications, plugins, modules, filters...
  19. 19. Dirty mix of routing patterns and straight module access </li></ul></ul><ul><li>Symfony 2 </li><ul><li>A controller can be easy as a simple PHP function
  20. 20. A base Controller class is supplied with several helper methods and can be used as standalone component
  21. 21. No routing, no party! Access to controller actions inside bundles MUST go through routing pattern matching </li></ul></ul>
  22. 22. Configuration <ul><li>Symfony 1.4 </li><ul><li>Configuration Cascade
  23. 23. Lots of yml files (app, factories, database, security, cache, etc ) distributed through apps, plugins and modules
  24. 24. You can get easily lost in a complex situation </li></ul></ul><ul><li>Symfony 2 </li><ul><li>Configuration files inside blundles must be included manually from outside
  25. 25. Less configuration files
  26. 26. The sole config.yml is incredibly powerful
  27. 27. With config.yml and routing.yml you can do almost everything :-) </li></ul></ul>
  28. 28. Handling Dependencies <ul><li>Symfony 1.4 </li><ul><li>Dependency handling is left to the developer
  29. 29. Service configuration limited to standard components
  30. 30. All mixed up in factories.yml
  31. 31. Non standard services if not properly handled may easily introduce coupling and poor testability </li></ul></ul><ul><li>Symfony 2 </li><ul><li>Service Container
  32. 32. Dependency Injection for full decoupling and high testability
  33. 33. Public and private services, tags, aliases </li></ul></ul>
  34. 34. Handling Dependencies – mailer example <ul><li>Symfony 1.4 </li></ul><ul><li>Symfony 2 </li></ul>
  35. 35. Validation <ul><li>Symfony 1.4 </li><ul><li>Embedded inside forms
  36. 36. Validators are not easily reusable in other contexts (for example webservices) </li></ul></ul><ul><li>Symfony 2 </li><ul><li>Validators are sticked to Entities
  37. 37. Configurable via Yaml, xml, annotations or PHP
  38. 38. Validators are called via the Service Container </li></ul></ul>
  39. 39. Validation <ul><li>Symfony 1.4 </li></ul><ul><li>Symfony 2 </li></ul>
  40. 40. Persistence - Doctrine <ul><li>Symfony 1.4 </li><ul><li>Bundled with the framework as a standard (with Propel as an alternative)
  41. 41. Active Record
  42. 42. Design requires lot of effort to make code fully testable </li></ul></ul><ul><li>Symfony 2 </li><ul><li>Totally decoupled from the framework via Service Container
  43. 43. Entities are independent from OR[D]M
  44. 44. Entities are mapped to DB via metadata definition (Yaml, xml, or annotations) </li></ul></ul>
  45. 45. Persistence - Doctrine <ul><li>Symfony 1.4 </li></ul>schema.yml <ul><li>Symfony 2 </li></ul>Product.orm.yml
  46. 46. Persistence - Doctrine <ul><li>Symfony 1 </li></ul><ul><li>Symfony 2 </li></ul>
  47. 47. Cache <ul><li>Symfony 1.4 </li><ul><li>Non-standard cache mechanism, though flexible and configurable </li></ul></ul><ul><li>Symfony 2 </li><ul><li>Standard RFC 2616 HTTP Cache </li></ul></ul>
  48. 48. Testing <ul><li>Symfony 1.4 </li><ul><li>Lime framework bundled as a standard, PHPUnit can be used as a plugin
  49. 49. Lime is not as powerful as PHPUnit </li></ul></ul><ul><li>Symfony 2 </li><ul><li>Fully integrated with PHPUnit framework
  50. 50. In functional tests internal objects can be fully inspected (kernel and DI container too!) </li></ul></ul>
  51. 51. Should I move to Symfony 2? Yes.
  52. 52. Giorgio Cefaro Twitter: @giorrrgio