Slide 1

Slide 1 text

Developing with Symfony 4 Victoria Quirante

Slide 2

Slide 2 text

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 [email protected]

Slide 3

Slide 3 text

SYMFONY EVOLUTION A brief history of time https://www.flickr.com/photos/gsfc/14411386334

Slide 4

Slide 4 text

Victoria Quirante @vicqr [email protected] Symfony evolution

Slide 5

Slide 5 text

Victoria Quirante @vicqr [email protected] Symfony evolution SF 1 SF 2 SF 3 SF 4 A different FW A new, better approach Monolithic

Slide 6

Slide 6 text

Victoria Quirante @vicqr [email protected] Symfony 2 was two things 1. A full stack framework 1. A full stack framework 2. A set of independent components

Slide 7

Slide 7 text

Victoria Quirante @vicqr [email protected] Symfony Components

Slide 8

Slide 8 text

Victoria Quirante @vicqr [email protected] Doctrine

Slide 9

Slide 9 text

Victoria Quirante @vicqr [email protected] Propel

Slide 10

Slide 10 text

Victoria Quirante @vicqr [email protected] Silex

Slide 11

Slide 11 text

Victoria Quirante @vicqr [email protected] Drupal

Slide 12

Slide 12 text

Victoria Quirante @vicqr [email protected] Laravel

Slide 13

Slide 13 text

Victoria Quirante @vicqr [email protected] Symfony evolution SF 1 SF 2 SF 3 SF 4 A different FW A new, better approach Symfony Components Dependency Injection

Slide 14

Slide 14 text

Victoria Quirante @vicqr [email protected] Dependency Injection Some code Some dependency created right here Coupled services Services decoupled with DI Some code Some dependency The dependency gets injected

Slide 15

Slide 15 text

Victoria Quirante @vicqr [email protected] 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

Slide 16

Slide 16 text

Victoria Quirante @vicqr [email protected] 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

Slide 17

Slide 17 text

Victoria Quirante @vicqr [email protected] 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

Slide 18

Slide 18 text

Victoria Quirante @vicqr [email protected] 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

Slide 19

Slide 19 text

Victoria Quirante @vicqr [email protected] Recent evolution of the web development environment Our favourite framework Some jQuery { { Back-end Front-end

Slide 20

Slide 20 text

Victoria Quirante @vicqr [email protected] 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

Slide 21

Slide 21 text

Victoria Quirante @vicqr [email protected] 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

Slide 22

Slide 22 text

Victoria Quirante @vicqr [email protected] 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

Slide 23

Slide 23 text

Victoria Quirante @vicqr [email protected] 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

Slide 24

Slide 24 text

Then, what is expected from a back-end framework nowadays?

Slide 25

Slide 25 text

Victoria Quirante @vicqr [email protected] 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

Slide 26

Slide 26 text

How does Symfony 4 provide this?

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

Victoria Quirante @vicqr [email protected] Symfony 2 was two things 1. A full stack framework 1. A full stack framework 2. A set of independent components

Slide 29

Slide 29 text

Victoria Quirante @vicqr [email protected] Symfony 2 was two things 1. A full stack framework But “developing in Symfony 2” generally meant “using the full framework”

Slide 30

Slide 30 text

Victoria Quirante @vicqr [email protected] Symfony 2 VS Symfony 4 graphically SF 2 web app SF 2 API SF 2 microservice

Slide 31

Slide 31 text

Victoria Quirante @vicqr [email protected] 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

Slide 32

Slide 32 text

Victoria Quirante @vicqr [email protected] Working with SF 4 SF 4 web app SF 4 API SF 4 microservice SF 4

Slide 33

Slide 33 text

«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

Slide 34

Slide 34 text

SF4 is not a new FW, it is a new mindset behind the same FW

Slide 35

Slide 35 text

Victoria Quirante @vicqr [email protected] Symfony 4 - Compose your application Make easy to create projects with lots or few dependencies For that, they wanted automate bundle installation/configuration

Slide 36

Slide 36 text

It is key that we can make our project grow or shrink very easily

Slide 37

Slide 37 text

Victoria Quirante @vicqr [email protected] Working with SF 4 SF 4 web app SF 4 API SF 4 microservice SF 4 We need something to smooth out this transformations

Slide 38

Slide 38 text

SYMFONY FLEX What exactly is it

Slide 39

Slide 39 text

SF FLEX is not a version of SF, it is a tool to implement SF4’s philosophy

Slide 40

Slide 40 text

«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

Slide 41

Slide 41 text

Victoria Quirante @vicqr [email protected] Symfony Flex - Automation to the max It is a composer plugin that comes with Symfony 4 Moving towards zero configuration time

Slide 42

Slide 42 text

Victoria Quirante @vicqr [email protected] Internals Modifies the behaviour of the require, update and remove commands Allows Symfony to perform tasks before or after the Composer commands

Slide 43

Slide 43 text

Victoria Quirante @vicqr [email protected] How does it work composer req mailer It installs and enables SwiftmailerBundle composer require mailer

Slide 44

Slide 44 text

Victoria Quirante @vicqr [email protected] 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

Slide 45

Slide 45 text

Victoria Quirante @vicqr [email protected] 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

Slide 46

Slide 46 text

Victoria Quirante @vicqr [email protected] 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

Slide 47

Slide 47 text

Any other big news in Symfony 4?

Slide 48

Slide 48 text

A great solution for the assets

Slide 49

Slide 49 text

Victoria Quirante @vicqr [email protected] 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

Slide 50

Slide 50 text

Victoria Quirante @vicqr [email protected] 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?

Slide 51

Slide 51 text

Victoria Quirante @vicqr [email protected] 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”

Slide 52

Slide 52 text

Victoria Quirante @vicqr [email protected] 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

Slide 53

Slide 53 text

STRENGTHS Andreas Fidler - https://unsplash.com/@speckfechta What is Symfony very good at

Slide 54

Slide 54 text

Good for large and small projects

Slide 55

Slide 55 text

Victoria Quirante @vicqr [email protected] 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

Slide 56

Slide 56 text

Victoria Quirante @vicqr [email protected] 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

Slide 57

Slide 57 text

Victoria Quirante @vicqr [email protected] "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

Slide 58

Slide 58 text

Victoria Quirante @vicqr [email protected] Good for large and small projects

Slide 59

Slide 59 text

Good if you know a lot or a little

Slide 60

Slide 60 text

Victoria Quirante @vicqr [email protected] 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

Slide 61

Slide 61 text

Good to develop “fast” and “slow”

Slide 62

Slide 62 text

Victoria Quirante @vicqr [email protected] 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

Slide 63

Slide 63 text

Whatever the case, it is going to help developing better code faster

Slide 64

Slide 64 text

It pushes you to write good code

Slide 65

Slide 65 text

Victoria Quirante @vicqr [email protected] It pushes you to write good code Decoupled services Thin controllers Clean templates ... Code that is easy to test, read, maintain and refactor

Slide 66

Slide 66 text

It makes easy to grow

Slide 67

Slide 67 text

It doesn’t matter how simple a project looks at the beginning... Andhrastea Pipperly - https://unsplash.com/@thepipperly

Slide 68

Slide 68 text

Complexity will find its way

Slide 69

Slide 69 text

It makes easy to grow

Slide 70

Slide 70 text

It makes easy to grow in a right way

Slide 71

Slide 71 text

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

Slide 72

Slide 72 text

Victoria Quirante @vicqr [email protected] 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

Slide 73

Slide 73 text

Victoria Quirante @vicqr [email protected] 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

Slide 74

Slide 74 text

Victoria Quirante @vicqr [email protected] 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

Slide 75

Slide 75 text

Victoria Quirante @vicqr [email protected] 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

Slide 76

Slide 76 text

The learning curve is not so steep, but there are easier things out there if you want

Slide 77

Slide 77 text

Victoria Quirante @vicqr [email protected] Some other solutions are... Easier to start with Perhaps not as flexible / powerful, but it depends on what you look for

Slide 78

Slide 78 text

Victoria Quirante @vicqr [email protected] Typing less saves time… Or not. It depends. difficulty to build sth simple difficulty to build sth complex

Slide 79

Slide 79 text

What the best tool is depends on your goals, your team, your resources Don’t be a hooligan

Slide 80

Slide 80 text

DEMO TIME Let’s create a project with Symfony Flex https://www.flickr.com/photos/callmewhatever/30708918322

Slide 81

Slide 81 text

Victoria Quirante @vicqr [email protected] Let’s create a project with Symfony Flex We are going to create a project with API Platform and EasyAdmin Victoria Quirante @vicqr [email protected]

Slide 82

Slide 82 text

Victoria Quirante @vicqr [email protected] API Platform Victoria Quirante @vicqr [email protected]

Slide 83

Slide 83 text

Victoria Quirante @vicqr [email protected] EasyAdmin Victoria Quirante @vicqr [email protected]

Slide 84

Slide 84 text

Victoria Quirante @vicqr [email protected] 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 [email protected]

Slide 85

Slide 85 text

WHAT ABOUT THE FUTURE Can we predict what will happen? https://www.flickr.com/photos/imagesnewman/33023955620

Slide 86

Slide 86 text

How does it feel developing in SF once you are comfortable with it?

Slide 87

Slide 87 text

Robert Szaskowski - https://unsplash.com/@robert_szadkowski As it should Boring

Slide 88

Slide 88 text

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

Slide 89

Slide 89 text

Victoria Quirante @vicqr [email protected] How does it feel developing with Symfony? Boring = Solid Consistent Predictable Tidy

Slide 90

Slide 90 text

Victoria Quirante @vicqr [email protected] 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

Slide 91

Slide 91 text

FINAL THOUGHTS What to remember https://www.flickr.com/photos/dewalick/15842170328

Slide 92

Slide 92 text

Victoria Quirante @vicqr [email protected] 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

Slide 93

Slide 93 text

Victoria Quirante @vicqr [email protected] 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) :)

Slide 94

Slide 94 text

Thanks! Victoria Quirante @vicqr [email protected]