Upgrade to Pro — share decks privately, control downloads, hide ads and more …

5 Years with Symfony

5 Years with Symfony

My talk at SymfonyCon 2016, a bit nostalgic retrospective of Symfony development since its early versions.

Pawel Jedrzejewski

December 01, 2016
Tweet

More Decks by Pawel Jedrzejewski

Other Decks in Technology

Transcript

  1. Lesson #1 Clicking a shiny banner is not always a

    bad idea. It can change your life in many posiKve ways. @pjedrzejewski
  2. Lesson #1 Time is the only resource that maNers. Save

    yours and reuse. Focus on what you do best. PS. Use Bundles for the rest. @pjedrzejewski
  3. Lesson #2 Websites for friends and family do not magically

    maintain and fix themselves. @pjedrzejewski
  4. Lesson #3 You rarely need to create a bundle. Do

    not use them as namespaces. @pjedrzejewski
  5. „A bundle is simply a structured set of files within

    a directory that implement a single feature.” @pjedrzejewski
  6. 2.0 -> 2.1 was easy. 2.1 -> 2.3 was hard.

    (forms) 2.3 -> 2.8 was smooth. 2.8 -> 3.0 was… hard, but it was our fault. @pjedrzejewski
  7. Lesson #4 Upgrade. If your project does not have resources

    for a Symfony upgrade, there is something much bigger broken than compaKbility. @pjedrzejewski
  8. 5m54.83s (678.72Mb) PHP 7 & Symfony 2.8 vs 4m38.20s (52.28Mb)

    PHP 7 & Symfony 3.2 13m6.17s (1.61Gb) PHP 5.6 & Symfony 2.8 vs 10m34.61s (96.04Mb) PHP 5.6 & Symfony 3.2 @pjedrzejewski
  9. Lesson #5 Be careful with sub requests. They are great,

    but loops are dangerous. @pjedrzejewski
  10. routing.yml app_reviews_index: path: /reviews defaults: _controller: app.controller.reviews:renderAction template: „@FooBar/Reviews/index.html.twig app_reviews_overview:

    path: /overview defaults: _controller: app.controller.reviews:renderAction template: „@FooBar/Reviews/_overview.html.twig limit: 5
  11. public function renderAction($template, $limit = 3) { $reviews = …;

    return $this->templating->renderResponse($template, [’reviews’ => $reviews]); }
  12. Migrating away from legacy It should always be a step-by-step

    process. Just wrap your legacy app with Symfony. Is full migraKon worth it? @pjedrzejewski
  13. Lesson #6 Do not push for a migraKon when not

    needed. Be smart about it. @pjedrzejewski
  14. Symfony FORMS Retrospective With great power comes great responsibility and

    yeah, processing forms is damn hard. @pjedrzejewski
  15. class TaskType extends AbstractType { public function buildForm(FormBuilder $builder, array

    $options) { $builder->add('task'); $builder->add('dueDate', null, array(…)); } public function getName() { return 'task'; } }
  16. Make a new form type, they are quite cheap now.

    Super-generic types are expensive. @pjedrzejewski
  17. Lesson #8 CRUD is great, but can be misused. AdminGenerators

    are great, but assuming too much can go wrong. @pjedrzejewski
  18. Integrating Symfony apps • API IntegraKons • Single-Kernel (Sylius +

    eZ Publish) • hNp:/ /stackphp.com/ @pjedrzejewski
  19. IntegraKng 2 Symfony apps, even via API is much nicer.

    Similar tools and approaches make it easy. Even details like directory structure.
  20. IDS are not unique enough If you applicaKon will integrate

    or share data with others. Unique codes will be your friend. @pjedrzejewski
  21. $ git clone [email protected]:netgen/ezplatform- sylius.git $ cd ezplatform-sylius $ composer

    install $ php app/console --env=prod sylius:install $ php app/console --env=prod ezplatform:install clean $ php app/console --env=prod assetic:dump $ php app/console --env=prod ezsylius:user:connect
  22. application contained in a bundle You can contain an enKre

    applicaKon in a bundle. Do not do it upfront, just apply good pracKces. @pjedrzejewski
  23. // AppKernel.php $bundles = array( new Sylius\Bundle\ShopBundle\SyliusShopBundle(), ); # config.yml

    imports: - { resource: "@SyliusShopBundle/Resources/config/ app/config.yml" } # routing.yml sylius_shop: resource: "@SyliusShopBundle/Resources/config/ routing.yml"
  24. State machines are awesome Relying on a state machine for

    business logic makes your life simpler. hNps:/ /engineering.shopify.com/17488160-why- developers-should-be-force-fed-state-machines @pjedrzejewski
  25. Open source is … EASY? We are just too busy

    doing it. Sharing more knowledge about Open Source pracKce, project maintenance and contribuKng is something we should work on. @pjedrzejewski
  26. 350+ Code contributors over 3,100,000 Downloads 600+ Translators 250 Pull

    Requests last month Over 19,000 Travis-CI Builds