Developing with Symfony 4

281604c1a5357a164f2a9cd6e403b4e3?s=47 Victoria Quirante
June 07, 2018
90

Developing with Symfony 4

Is Symfony 4 the framework that you want to use for your next project? Since its release back in 2005, Symfony has been continuously evolving and improving. With every new version the framework has pushed forward, helping us writing better code faster. But there are many different types of projects and developers out there, and it is always good to get some insight in a technology before jumping into it. In this talk we will analyze the strengths and weaknesses of the framework, checking them against other alternatives, and learning the type of projects and developers that can benefit from it to a larger extent. We will also review the most important changes introduced in the last version of Symfony, understanding the motivations behind them, evaluating the current state of the framework in the web development environment, and trying to foresee the future of this technology.

281604c1a5357a164f2a9cd6e403b4e3?s=128

Victoria Quirante

June 07, 2018
Tweet

Transcript

  1. Developing with Symfony 4 Victoria Quirante

  2. I work at Limenius We build tailor-made projects with Symfony

    and React We have been working with Symfony since 2008 Symfony 4 has been a significant evolution Victoria Quirante @vicqr victoria@limenius.com
  3. SYMFONY EVOLUTION A brief history of time https://www.flickr.com/photos/gsfc/14411386334

  4. Victoria Quirante @vicqr victoria@limenius.com Symfony evolution

  5. Victoria Quirante @vicqr victoria@limenius.com Symfony evolution SF 1 SF 2

    SF 3 SF 4 A different FW A new, better approach Monolithic
  6. Victoria Quirante @vicqr victoria@limenius.com Symfony 2 was two things 1.

    A full stack framework 1. A full stack framework 2. A set of independent components
  7. Victoria Quirante @vicqr victoria@limenius.com Symfony Components

  8. Victoria Quirante @vicqr victoria@limenius.com Doctrine

  9. Victoria Quirante @vicqr victoria@limenius.com Propel

  10. Victoria Quirante @vicqr victoria@limenius.com Silex

  11. Victoria Quirante @vicqr victoria@limenius.com Drupal

  12. Victoria Quirante @vicqr victoria@limenius.com Laravel

  13. Victoria Quirante @vicqr victoria@limenius.com Symfony evolution SF 1 SF 2

    SF 3 SF 4 A different FW A new, better approach Symfony Components Dependency Injection
  14. Victoria Quirante @vicqr victoria@limenius.com Dependency Injection Some code Some dependency

    created right here Coupled services Services decoupled with DI Some code Some dependency The dependency gets injected
  15. Victoria Quirante @vicqr victoria@limenius.com Symfony evolution SF 1 SF 2

    SF 3 SF 4 A different FW A step in between A new, better approach Symfony Components Dependency Injection More modular More flexible More decoupled
  16. Victoria Quirante @vicqr victoria@limenius.com Symfony evolution SF 1 SF 2

    SF 3 SF 4 A different FW A step in between What has changed between these two and why? Many dependencies High configuration times Steep learning curve
  17. Victoria Quirante @vicqr victoria@limenius.com Symfony evolution SF 1 SF 2

    SF 3 SF 4 A different FW A step in between They have tried to keep/enhance the good and improve the bad Many dependencies High configuration times Steep learning curve
  18. Victoria Quirante @vicqr victoria@limenius.com Symfony evolution SF 1 SF 2

    SF 3 SF 4 A different FW A step in between Many dependencies High configuration times Steep learning curve And adapt to the challenges of the current web development environment
  19. Victoria Quirante @vicqr victoria@limenius.com Recent evolution of the web development

    environment Our favourite framework Some jQuery { { Back-end Front-end
  20. Victoria Quirante @vicqr victoria@limenius.com Recent evolution of the web development

    environment Our favourite framework Some jQuery { { Back-end Front-end Backbone.js Ember.js Angular.js Gulp Grunt Vue.js Webpack React.js chats notifications immediate validations page reloads
  21. Victoria Quirante @vicqr victoria@limenius.com Our favourite framework Some jQuery Recent

    evolution of the web development environment { { Back-end Front-end Our favourite front-end framework Our favourite back-end framework API Backbone.js Ember.js Angular.js Gulp Grunt Vue.js Webpack React.js chats notifications immediate validations page reloads
  22. Victoria Quirante @vicqr victoria@limenius.com Our favourite framework Some jQuery Recent

    evolution of the web development environment { { Back-end Front-end Our favourite front-end framework Our favourite back-end framework API Our favourite front-end framework API
  23. Victoria Quirante @vicqr victoria@limenius.com Our favourite framework Some jQuery Recent

    evolution of the web development environment { { Back-end Front-end Our favourite front-end framework Our favourite back-end framework API Our favourite front-end framework API API API API API
  24. Then, what is expected from a back-end framework nowadays?

  25. Victoria Quirante @vicqr victoria@limenius.com What is expected from a back-end

    framework nowadays? - To be a great solution for APIs - To make easy to build some functionalities (admin panels, etc.) - To be efficient creating small apps and microservices - ... To take good care of the back-end And, ideally, to play well with the front-end
  26. How does Symfony 4 provide this?

  27. SYMFONY 4 PHILOSOPHY https://www.flickr.com/photos/68532869@N08/16357411958 How are things now

  28. Victoria Quirante @vicqr victoria@limenius.com Symfony 2 was two things 1.

    A full stack framework 1. A full stack framework 2. A set of independent components
  29. Victoria Quirante @vicqr victoria@limenius.com Symfony 2 was two things 1.

    A full stack framework But “developing in Symfony 2” generally meant “using the full framework”
  30. Victoria Quirante @vicqr victoria@limenius.com Symfony 2 VS Symfony 4 graphically

    SF 2 web app SF 2 API SF 2 microservice
  31. Victoria Quirante @vicqr victoria@limenius.com Symfony 2 VS Symfony 4 graphically

    SF 2 web app SF 2 API SF 2 microservice SF 4 web app SF 4 API SF 4 microservice
  32. Victoria Quirante @vicqr victoria@limenius.com Working with SF 4 SF 4

    web app SF 4 API SF 4 microservice SF 4
  33. «As a developer, I want to start small, without too

    many dependencies. But I also want to be able to grow my application as I see fit. From a micro-framework style app to a gigantic monolith. Your choice. The framework should not get in the way.» Fabien Potencier
  34. SF4 is not a new FW, it is a new

    mindset behind the same FW
  35. Victoria Quirante @vicqr victoria@limenius.com Symfony 4 - Compose your application

    Make easy to create projects with lots or few dependencies For that, they wanted automate bundle installation/configuration
  36. It is key that we can make our project grow

    or shrink very easily
  37. Victoria Quirante @vicqr victoria@limenius.com Working with SF 4 SF 4

    web app SF 4 API SF 4 microservice SF 4 We need something to smooth out this transformations
  38. SYMFONY FLEX What exactly is it

  39. SF FLEX is not a version of SF, it is

    a tool to implement SF4’s philosophy
  40. «Symfony Flex is all about making it simple and easy

    to create any Symfony applications, from the most simple micro-style project to the more complex ones with dozens of dependencies. It automates adding and removing bundles. It takes care of giving you sensible defaults. It helps discovering good bundles.» Fabien Potencier
  41. Victoria Quirante @vicqr victoria@limenius.com Symfony Flex - Automation to the

    max It is a composer plugin that comes with Symfony 4 Moving towards zero configuration time
  42. Victoria Quirante @vicqr victoria@limenius.com Internals Modifies the behaviour of the

    require, update and remove commands Allows Symfony to perform tasks before or after the Composer commands
  43. Victoria Quirante @vicqr victoria@limenius.com How does it work composer req

    mailer It installs and enables SwiftmailerBundle composer require mailer
  44. Victoria Quirante @vicqr victoria@limenius.com How does it work Your application

    with Symfony Flex composer require mailer Is there information about this package? Going for regular installation via Composer Nope Symfony Flex server
  45. Victoria Quirante @vicqr victoria@limenius.com How does it work Your application

    with Symfony Flex composer require mailer Is there information about this package? Asking Composer to install them Yes, sending recipe Cool, following recipe instructions! Deciding which packages to install Running any required tasks Symfony Flex server
  46. Victoria Quirante @vicqr victoria@limenius.com Creating a new Symfony app with

    Symfony Flex composer create-project symfony/skeleton my-project "require": { "php": "^7.1.3", "ext-iconv": "*", "symfony/console": "^4.0", "symfony/flex": "^1.0", "symfony/framework-bundle": "^4.0", "symfony/lts": "^4@dev", "symfony/yaml": "^4.0" }, Downloads the Symfony skeleton (just one composer.json) composer install And runs As soon as Symfony Flex is installed, it hooks into the process
  47. Any other big news in Symfony 4?

  48. A great solution for the assets

  49. Victoria Quirante @vicqr victoria@limenius.com Webpack Encore It simplifies the integration

    of our Symfony project with Webpack Webpack is a great tool to process the assets Configuring Webpack is not easy But Webpack Encore solves that Working together with the front-end, not fighting against it
  50. Victoria Quirante @vicqr victoria@limenius.com Keeping/enhancing the good and improving the

    bad SF 1 SF 2 SF 3 SF 4 A different FW A step in between What has changed between these two?
  51. Victoria Quirante @vicqr victoria@limenius.com Solid Powerful Flexible Good for large

    long-term projects Keeping/enhancing the good and improving the bad Steep learning curve High configuration times Many dependencies A bit too much for small/quick projects A bit too much for small/quick projects -> Good for small/quick projects Many dependencies -> Only the dependencies you need High configuration times -> Low configuration times (if you want) Steep learning curve -> You can start “easy”
  52. Victoria Quirante @vicqr victoria@limenius.com Keeping/enhancing the good and improving the

    bad SF 1 SF 2 SF 3 SF 4 A different FW A step in between Equally powerful More flexible Easier to start with Lower configuration times Better integration with the front-end Moved further towards standardization A new, better approach
  53. STRENGTHS Andreas Fidler - https://unsplash.com/@speckfechta What is Symfony very good

    at
  54. Good for large and small projects

  55. Victoria Quirante @vicqr victoria@limenius.com Good for large and small projects

    You don’t have to carry unneeded dependencies The feeling of “SF is too much for this project” is not there anymore
  56. Victoria Quirante @vicqr victoria@limenius.com Good for large and small projects

    APIs Admin panels Mobile backends Enterprise software Complex web apps Prototypes MVPs Side projects Simple web apps Presentation sites
  57. Victoria Quirante @vicqr victoria@limenius.com "require": { "php": "^7.1.3", "ext-iconv": "*",

    "symfony/console": "^4.0", "symfony/flex": "^1.0", "symfony/framework-bundle": "^4.0", "symfony/lts": "^4@dev", "symfony/yaml": "^4.0" } "require": { "php": "^7.1.3", "ext-iconv": "*", "sensio/framework-extra-bundle": "^5.1", "symfony/asset": "^4.0", "symfony/console": "^4.0", "symfony/expression-language": "^4.0", "symfony/flex": "^1.0", "symfony/form": "^4.0", "symfony/framework-bundle": "^4.0", "symfony/lts": "^4@dev", "symfony/monolog-bundle": "^3.1", "symfony/orm-pack": "*", "symfony/process": "^4.0", "symfony/security-bundle": "^4.0", "symfony/serializer-pack": "*", "symfony/swiftmailer-bundle": "^3.1", "symfony/twig-bundle": "^4.0", "symfony/validator": "^4.0", "symfony/web-link": "^4.0", "symfony/webpack-encore-pack": "*", "symfony/yaml": "^4.0" } "A minimal Symfony project recommended to create bare bones applications" "A skeleton to start a new Symfony website" symfony/skeleton symfony/website-skeleton
  58. Victoria Quirante @vicqr victoria@limenius.com Good for large and small projects

  59. Good if you know a lot or a little

  60. Victoria Quirante @vicqr victoria@limenius.com Good if you know a lot

    or a little You can start using SF without a deep understanding of the FW Understanding the FW will allow you to master it
  61. Good to develop “fast” and “slow”

  62. Victoria Quirante @vicqr victoria@limenius.com Good to develop fast and slow

    With Symfony you can go for RAD SF makes your life easier, but the decisions are yours Emphasizing working software and user feedback over strict planning and requirements recording But you can also go for DDD/CQRS if you want
  63. Whatever the case, it is going to help developing better

    code faster
  64. It pushes you to write good code

  65. Victoria Quirante @vicqr victoria@limenius.com It pushes you to write good

    code Decoupled services Thin controllers Clean templates ... Code that is easy to test, read, maintain and refactor
  66. It makes easy to grow

  67. It doesn’t matter how simple a project looks at the

    beginning... Andhrastea Pipperly - https://unsplash.com/@thepipperly
  68. Complexity will find its way

  69. It makes easy to grow

  70. It makes easy to grow in a right way

  71. “WEAKNESSES”... Or what is Symfony not suited for

  72. Victoria Quirante @vicqr victoria@limenius.com Not the coolest newest thing Symfony

    is a mature technology It helps you writing better code faster Helping you looking cool is not part of its work
  73. Victoria Quirante @vicqr victoria@limenius.com Not a front-end framework! Rich front-ends

    require a front-end framework Don’t try to build a rich front-end with a back-end framework
  74. Victoria Quirante @vicqr victoria@limenius.com Not if there is nothing custom

    in your software Symfony helps a lot building custom software If you want to build something very standard, SF won’t save time
  75. Victoria Quirante @vicqr victoria@limenius.com Not if you want everything done

    for you Symfony makes life easier, but it needs you to work and take decisions If you want everything done out-of-the-box, pick something else
  76. The learning curve is not so steep, but there are

    easier things out there if you want
  77. Victoria Quirante @vicqr victoria@limenius.com Some other solutions are... Easier to

    start with Perhaps not as flexible / powerful, but it depends on what you look for
  78. Victoria Quirante @vicqr victoria@limenius.com Typing less saves time… Or not.

    It depends. difficulty to build sth simple difficulty to build sth complex
  79. What the best tool is depends on your goals, your

    team, your resources Don’t be a hooligan
  80. DEMO TIME Let’s create a project with Symfony Flex https://www.flickr.com/photos/callmewhatever/30708918322

  81. Victoria Quirante @vicqr victoria@limenius.com Let’s create a project with Symfony

    Flex We are going to create a project with API Platform and EasyAdmin Victoria Quirante @vicqr victoria@limenius.com
  82. Victoria Quirante @vicqr victoria@limenius.com API Platform Victoria Quirante @vicqr victoria@limenius.com

  83. Victoria Quirante @vicqr victoria@limenius.com EasyAdmin Victoria Quirante @vicqr victoria@limenius.com

  84. Victoria Quirante @vicqr victoria@limenius.com composer create-project symfony/skeleton apiadmin-project cd apiadmin-project

    composer req api composer req admin composer req webserver - Create Entity - Config database bin/console doctrine:schema:update - Tell API Platform and EasyAdmin about our Entity bin/console server:run Demo time Let’s do it Victoria Quirante @vicqr victoria@limenius.com
  85. WHAT ABOUT THE FUTURE Can we predict what will happen?

    https://www.flickr.com/photos/imagesnewman/33023955620
  86. How does it feel developing in SF once you are

    comfortable with it?
  87. Robert Szaskowski - https://unsplash.com/@robert_szadkowski As it should Boring

  88. Blake Lipthratt - https://unsplash.com/@blake_lipthratt As it should Boring

  89. Victoria Quirante @vicqr victoria@limenius.com How does it feel developing with

    Symfony? Boring = Solid Consistent Predictable Tidy
  90. Victoria Quirante @vicqr victoria@limenius.com We cannot predict but... SF has

    proven to be a powerful and solid solution for backends Companies like mature technologies Many have been/are changing their spaghetti code to SF The FW is successfully adapting the new challenges We are going to need APIs, admin panels, etc. for a long time Imho, SF is going to be around for a good while
  91. FINAL THOUGHTS What to remember https://www.flickr.com/photos/dewalick/15842170328

  92. Victoria Quirante @vicqr victoria@limenius.com Summarizing SF4 has been a significant

    evolution On top of a mature, powerful, flexible framework It is possible to start easy And make something as complex as you need While following best practices and keeping your code nice and clean That makes it for me a very good choice for the back-end
  93. Victoria Quirante @vicqr victoria@limenius.com Summarizing It is a mature, powerful,

    flexible framework It is not the one with the easiest learning curve But it is possible to start easy And make something as complex as you need While following best practices and keeping your code nice and clean That makes it for me a very good choice for the back-end It may be also for you (or not) :)
  94. Thanks! Victoria Quirante @vicqr victoria@limenius.com