Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

How Symfony changed my life (#SfPot, Paris, 19th November 2015)

2.093 Aufrufe

Veröffentlicht am

Before Symfony was spelled with a capital “S” there was another symfony, the first version of the framework. It already meant a lot to me at the time. But with the arrival of Symfony 2 it became clear that something very important was happening in the world of PHP programming. It appears that this framework is able to turn amateur website makers (like I used to be) into actual software developers. What is the secret? What makes Symfony so special? And why am I still hooked?

We’ll look at pieces of code, the Symfony ecosystem, the people behind it, the things that have been written about it, and the experience that I have with it. We’ll take a trip down memory lane, collecting pieces for our Symfony scrapbook, while we try to construct an answer to these questions.

Veröffentlicht in: Software
  • Loggen Sie sich ein, um Kommentare anzuzeigen.

How Symfony changed my life (#SfPot, Paris, 19th November 2015)

  1. 1. Matthias Noback Paris, November 19th 2015 10 years! How Symfony changed my life
  2. 2. Pre-symfony
  3. 3. From ASP using VBScript and a MS Access database To PHP with a MySQL database "You should try PHP!"
  4. 4. From include('script.php') To proper function calls
  5. 5. From PHP 4 and one mega Page class To PHP 5 with proper scoping for methods and properties, and autoloading
  6. 6. From PHP & HTML in the same file To PHP classes and Smarty template files
  7. 7. From copying snippets from the Internet To downloading single-purpose libraries
  8. 8. Feeling mighty fine SQL injection Register globals Session hijacking Magic quotes CSRF XSS
  9. 9. Basically...
  10. 10. But... performance was very good ;)
  11. 11. Driebit (2008)
  12. 12. symfony (1) with a lower-case s
  13. 13. Symfony Camp (2007) Stefan Koopmanschap
  14. 14. The Book (back then) François Zaninotto (Propel) symfony 1.1
  15. 15. Working with symfony 1 meant... MVC Fat controllers Fat models (Zend devs wrote fat services as well)
  16. 16. Not in the controller or the model? Put it in: A "peer" class A utility class Or: create a global singleton for it
  17. 17. What's a singleton? Static Global Single instance class Singleton
 private static $instance;
 private function __construct()
 public static function getInstance()
 if (self::$instance === null) {
 self::$instance = new self();
 return self::$instance;
  18. 18. God object sfContext::getInstance() getUser(), getResponse(), getRequest(), getLogger(), getI18N(), ...
  19. 19. Just reach out
  20. 20. Why bad? Testability Isolation Side-effects Configuration No separation of concerns
  21. 21. CTO at SensioLabs DE
  22. 22. Pushing the limits
  23. 23. Tweaking symfony Event listeners: add missing methods on the fly (!) Filters: chain of responsibility factories.yml and other config files
  24. 24. Switch to Doctrine It was... new version 1.0
  25. 25. Develop some Plugins
  26. 26. Learn about advanced topics Emails Forms Doctrine Internals
  27. 27. SymfonyLive Paris 2010 Revealing Symfony2
  28. 28. SymfonyLive Paris 2011 Almost releasing Symfony 2.0 Excitement all over the place
  29. 29. Start using 2.0? No backwards compatibility No best practices No CMS
  30. 30. Not even... ... an admin generator only for scaffolding ;)
  31. 31. Migrating to 2.0? Company owners didn't dare to take the step (I agree with them now!) I left the company :)
  32. 32. Symfony2 capital "S" no space, for Google
  33. 33. Infrastructure 1. Git for version control 2. Install script or Git submodules for vendor code 3. At some point: composer started handling dependencies
  34. 34. Templating Twig: Own syntax No PHP code "Auto-safe" Fast (the engine that is) "Templating engines in PHP" by Fabien Potencier
  35. 35. Dependency injection container Major improvement: everything can be configured No runtime resolvers anymore
  36. 36. What's dependency injection? class Foo
 private $bar;
 public function __construct(Bar $bar)
 $this->bar = $bar;
  37. 37. What's a DI container? class Container
 public function createFoo()
 return new Foo($this->getBar());
 private function createBar()
 return new Bar();
  38. 38. What does DI give us? Single responsibility Testability Dependency inversion Speed Flexibility
  39. 39. Active record -> data mapper Doctrine 1/Propel Doctrine 2/...
  40. 40. Active record sample class Invoice extends Record
 $invoice = new Invoice();
  41. 41. Data mapper sample class Invoice
 $invoice = new Invoice();
 $entityManager->persist($invoice); POPO
  42. 42. Why is that better? Isolation Model first Decoupling (not always a good reason)
  43. 43. Bundle ~= Plugin
  44. 44. First-class citizens
  45. 45. A bundle for each feature
  46. 46. Framework coupling Libraries are framework- independent Bundles are explicitly meant to couple code to the framework
  47. 47. Bundles: service definitions Service definition files Bundle extension Bundle configuration Compiler pass
  48. 48. Bundle: root for resources @MyBundle/Resources/views/ template.html.twig
  49. 49. Resources Expose: Templates Translations ...
  50. 50. Assets Assetic Separate tools (non-PHP based)
  51. 51. Security So very hard Documented in many different ways It's really good though Simplified at code level now
  52. 52. Symfony is an early adopter PHP-FIG PSR-0, PSR-1, PSR-2, PSR-3, PSR-7 - very quickly adopted
  53. 53. Extensive documentation High quality Friendly Good- looking Well maintained
  54. 54. "The Book"?
  55. 55. Excellent BC promise @api
  56. 56. A Year With Symfony
  57. 57. Struggling with framework coupling
  58. 58. The fight against CRUD
  59. 59. Hexagonal architecture
  60. 60. phparchitecturetour.com
  61. 61. Conclusion
  62. 62. Symfony - The biggest change Dependency injection (container) Which is an enabler for better code Because: maintainable and testable
  63. 63. My personal development: 1. I love symfony 2. I love Symfony2 3. I want to decouple from it 4. I want to fully embrace it whenever that's okay
  64. 64. For me it's about Knowing your framework Being fast with it Not being totally dependent on it
  65. 65. Long live SfPot!