Slide 1

Slide 1 text

Symfony4 A new way to develop web applications Antonio Perić-Mažar, Locastic

Slide 2

Slide 2 text

Antonio Perić-Mažar CEO @ Locastic Co-Organizer @ BlockSplit Conference Tinel Meetup [email protected] @antonioperic @antonioperic

Slide 3

Slide 3 text

Locastic ● We help clients create amazing web and mobile apps (since 2011) ○ mobile development ○ web development ○ UX/UI ○ Training and Consulting ● @locastic ● www.locastic.com ● Split, Croatia @antonioperic

Slide 4

Slide 4 text

@antonioperic Photo: Goran Leš

Slide 5

Slide 5 text

Text @antonioperic https://lifestyle.clickhole.com/the-evolution-of-man-7-new-physical-traits-that-humans-1825122200

Slide 6

Slide 6 text

Text @antonioperic

Slide 7

Slide 7 text

Text @antonioperic

Slide 8

Slide 8 text

Text @antonioperic

Slide 9

Slide 9 text

Text @antonioperic 30.11.2017

Slide 10

Slide 10 text

@antonioperic Fabien Potencier

Slide 11

Slide 11 text

We can do better ● Installing a Bundle is too cumbersome ● Remove a Bundle is too cumbersome @antonioperic

Slide 12

Slide 12 text

We can do better ● Installing a Bundle is too cumbersome ● Remove a Bundle is too cumbersome ● The standard edition is not good enough @antonioperic

Slide 13

Slide 13 text

We can do better ● Installing a Bundle is too cumbersome ● Remove a Bundle is too cumbersome ● The standard edition is not good enough ● You always have a lot of code that you are not using but it is to hard to remove it @antonioperic

Slide 14

Slide 14 text

@antonioperic Fabien Potencier

Slide 15

Slide 15 text

Symfony4 ● Starting as micro framework ● Compose your application / setup your stack ● Build API, console app, traditional web app or whatever you want @antonioperic

Slide 16

Slide 16 text

@antonioperic

Slide 17

Slide 17 text

Symfony Flex ● Composer plugin ● Auto-configuration via recipes @antonioperic

Slide 18

Slide 18 text

Symfony Flex ● Composer plugin ● Auto-configuration via recipes @antonioperic Fabien Potencier

Slide 19

Slide 19 text

Symfony flex @antonioperic

Slide 20

Slide 20 text

Symfony flex @antonioperic

Slide 21

Slide 21 text

Mailer manifest.json @antonioperic

Slide 22

Slide 22 text

Symfony flex recipies ● Two repositories ● symfony/recipies ○ maintained by Symfony Core Team and holds only recipies for Symfony components and bundles ‘opinionated’ by them ○ Can use alias ● symfony/recipies-contrib ○ Anyone can contribute ○ Cannot use alias @antonioperic

Slide 23

Slide 23 text

www.symfony.sh @antonioperic

Slide 24

Slide 24 text

Directory structure @antonioperic

Slide 25

Slide 25 text

Directory structure @antonioperic

Slide 26

Slide 26 text

Directory structure @antonioperic we say goodby to app.php and app_dev.php — this is now one standard index.php file and environment is set with environmental variable APP_ENV

Slide 27

Slide 27 text

Directory structure @antonioperic

Slide 28

Slide 28 text

Directory structure @antonioperic

Slide 29

Slide 29 text

Directory structure @antonioperic

Slide 30

Slide 30 text

Directory structure @antonioperic Flex keeps tracks of the recipes it installed in a symfony.lock file, which must be committed to your code repository.

Slide 31

Slide 31 text

Bundle-less applications ● Bundle vs no-bundle apps ● All in src folder ○ App/ namespace ○ You should separate, but no need for bundles ● Moving forward to standardisation ● It reduces the perceived complexity, also makes your code feels more decoupled from symfony ● Bundle inheritance mechanisms are deprecated in 3.4 and were removed in 4.0 @antonioperic

Slide 32

Slide 32 text

Let’s call this a small demo - Our task will be to create simple Symfony console application, a web crawler - Steps: - Create new symfony application - composer create-project symfony/skeleton my_project - Add Console component - Add Doctrine - Add Symfony Crawler component - Do some code (we will not do code, idea is just to see the flow of working with Symfony4) @antonioperic

Slide 33

Slide 33 text

Create new Symfony4 application @antonioperic

Slide 34

Slide 34 text

Create new Symfony4 application @antonioperic

Slide 35

Slide 35 text

Add components ● Composer req cli ● Composer req doctrine ● Composer req symfony/dom-crawler @antonioperic

Slide 36

Slide 36 text

Autowiring ● Introduced in Symfony 3 version ● Autowiring allows you to manage services in the container with minimal configuration ● It reads the type-hints on your constructor (or other methods) and automatically passes the correct services to each method. ● Symfony's autowiring is designed to be predictable: if it is not absolutely clear which dependency should be passed, you'll see an actionable exception. @antonioperic

Slide 37

Slide 37 text

Autowire @antonioperic

Slide 38

Slide 38 text

Autowiring @antonioperic

Slide 39

Slide 39 text

Symfony Webpack Encore ● Webpack encore is a simpler way to integrate Webpack into your application ● Step forward after AsseticBundle ● composer require webpack-encore ● It can work outside of Symfony @antonioperic

Slide 40

Slide 40 text

About me Text @antonioperic

Slide 41

Slide 41 text

DotEnv component ● The Dotenv Component parses .env files to make environment variables stored in them accessible via getenv(), $_ENV or $_SERVER. ● composer require symfony/dotenv @antonioperic

Slide 42

Slide 42 text

DotEnv component @antonioperic

Slide 43

Slide 43 text

Performance Hello world test @antonioperic Fabien Potencier

Slide 44

Slide 44 text

Performance @antonioperic

Slide 45

Slide 45 text

Performance @antonioperic Fabien Potencier

Slide 46

Slide 46 text

Updating to Symfony ● It is possible, not even to complex ● Need a little bit of time ● If you are using Symfony2.x, upgrade first to 3.4 @antonioperic

Slide 47

Slide 47 text

Symfony 4.1 improvements ● Made csrf_token() useable without forms ● Csv processor for env variables ● Display DotEnv variables in profiler ● Session improvements ● Console improvements ● Workflow improvements ● Messenger component https://symfony.com/blog/symfony-4-1-curated-new- features @antonioperic

Slide 48

Slide 48 text

Roadmap @antonioperic

Slide 49

Slide 49 text

7 months later ● It is great feeling to works with Symfony4 ● Seems that Fabien and core team are making great progress moving Symfony forward ● I love Flex ● It is seems much more natural to navigate through new code structure and DX is much better ● Symfony community is awesome @antonioperic

Slide 50

Slide 50 text

7 months later ● Symfony is great as microframework ● With higher level of abstraction is more better for prototyping and building things fast ● It will be much easier to start, but maybe even harder to master for newbies (symfony2 wasn’t easy to master) @antonioperic

Slide 51

Slide 51 text

Thank you! @antonioperic

Slide 52

Slide 52 text

Questions? @antonioperic