Slide 1

Slide 1 text

Symfony Nano Framework It’s so minute it wouldn’t be able to cover a small water biscuit Loïc Faugeron http://constant.co @epiloic

Slide 2

Slide 2 text

Loïc Faugeron gnugat @epiloic Blog - https://gnugat.github.io 2

Slide 3

Slide 3 text

Constant Commerce Symfony 3, PHP 7, phpspec @epiloic Site - http://constant.co 3

Slide 4

Slide 4 text

Symfony Nano Framework Micro @epiloic 4

Slide 5

Slide 5 text

1. Micro Framework? 2. Standard Edition 3. Symfony Flex 4. Empty Edition 5. Micro Framework Bundle

Slide 6

Slide 6 text

1. Micro Framework? What does it mean for you?

Slide 7

Slide 7 text

@epiloic 7 Examples ● Laravel: Lumen ● Zend: Expressive ● Symfony: ???

Slide 8

Slide 8 text

@epiloic 8 Silex? Bundles Incompatibility

Slide 9

Slide 9 text

@epiloic 9 MicroKernelTrait? Fabpot: It’s just a regular Kernel with some method helpers [...] There’s nothing micro here See Fabien’s comments - https://github.com/symfony/symfony/pull/15990#r40645358

Slide 10

Slide 10 text

@epiloic 10 Symfony?

Slide 11

Slide 11 text

@epiloic 11 ● HttpKernel ● Routing ● DependencyInjection ● EventDispatcher ● Config

Slide 12

Slide 12 text

@epiloic 12 Hello World

Slide 13

Slide 13 text

@epiloic 13 Metrics

Slide 14

Slide 14 text

@epiloic 14 API (usage in your app) Number of steps to add new route

Slide 15

Slide 15 text

@epiloic 15 Dependencies composer show | wc -l

Slide 16

Slide 16 text

@epiloic 16 Footprint Apache Benchmark and Blackadder Blackfire

Slide 17

Slide 17 text

2. Standard Edition Solves 80%, out of the box

Slide 18

Slide 18 text

@epiloic 18 composer create-project symfony/framework-standard-edition cd framework-standard-edition

Slide 19

Slide 19 text

@epiloic 19

Slide 20

Slide 20 text

@epiloic 20 SYMFONY_ENV=prod composer update -oa --no-dev php -S localhost:2502 -t web & curl 'http://localhost:2502/app.php' ab -c 10 -t 10 'http://localhost:2502/app.php' killall php

Slide 21

Slide 21 text

@epiloic 21 Results ● API: 1 step to add new route ● Dependencies: 85 (34 + 51) ● Footprint: 400 req / s

Slide 22

Slide 22 text

@epiloic 22

Slide 23

Slide 23 text

3. Symfony Flex Add what you need

Slide 24

Slide 24 text

@epiloic 24 composer create-project symfony/skeleton:3.3.x-dev cd skeleton composer require symfony/dotenv

Slide 25

Slide 25 text

@epiloic 25 # .env ###> symfony/framework-bundle ### APP_ENV=prod APP_DEBUG=0 APP_SECRET=31611929636ceb325e27091c2856ab8b ###< symfony/framework-bundle ###

Slide 26

Slide 26 text

@epiloic 26

Slide 27

Slide 27 text

@epiloic 27 # etc/routing.yaml hello_world: path: / defaults: _controller: ‘App\Controller\HelloController:world’ methods: - GET

Slide 28

Slide 28 text

@epiloic 28 composer update -oa --no-dev php -S localhost:2504 -t web & curl 'http://localhost:2504/index.php' ab -c 10 -t 10 'http://localhost:2504/index.php' killall php

Slide 29

Slide 29 text

@epiloic 29 Results ● API: 2 steps to add new route [+1] ● Dependencies: 28 [/3] ● Footprint: 950 req / s [x2.5]

Slide 30

Slide 30 text

@epiloic 30

Slide 31

Slide 31 text

@epiloic 31

Slide 32

Slide 32 text

4. Empty Edition Add what you need

Slide 33

Slide 33 text

@epiloic 33 composer create-project gnugat/symfony-empty-edition cd symfony-empty-edition

Slide 34

Slide 34 text

@epiloic 34

Slide 35

Slide 35 text

@epiloic 35 # app/config/services/controller.yml services: app.hello_controller: class: ‘AppBundle\Controller\HelloController’

Slide 36

Slide 36 text

@epiloic 36 # app/config/routings/app.yml hello_world: path: / defaults: _controller: app.hello_controller:world methods: - GET

Slide 37

Slide 37 text

@epiloic 37 SYMFONY_ENV=prod composer update -oa --no-dev php -S localhost:2503 -t web & curl 'http://localhost:2503/app.php' ab -c 10 -t 10 'http://localhost:2503/app.php' killall php

Slide 38

Slide 38 text

@epiloic 38 Results ● API: 3 steps to add new route [+1] ● Dependencies: 25 [/1.1] ● Footprint: 1 000 req / s [x1.1]

Slide 39

Slide 39 text

@epiloic 39

Slide 40

Slide 40 text

@epiloic 40

Slide 41

Slide 41 text

5. MicroFrameworkBundle Add what you need++

Slide 42

Slide 42 text

@epiloic 42 composer require gnugat/micro-framework-bundle composer remove symfony/framework-bundle

Slide 43

Slide 43 text

@epiloic 43

Slide 44

Slide 44 text

@epiloic 44 # app/config/config.yml imports: - { resource: parameters.yml } - { resource: services/ }

Slide 45

Slide 45 text

@epiloic 45 rm -rf var/* SYMFONY_ENV=prod composer update -o --no-dev php -S localhost:2505 -t web & curl 'http://localhost:2505/app.php' ab -c 10 -t 10 'http://localhost:2505/app.php' killall php

Slide 46

Slide 46 text

@epiloic 46

Slide 47

Slide 47 text

@epiloic 47 Results ● API: 3 steps to add new route [0] ● Dependencies: 16 [/1.5] ● Footprint: 1 200 req / s [x1.2]

Slide 48

Slide 48 text

Conclusion

Slide 49

Slide 49 text

@epiloic 49 Questions?

Slide 50

Slide 50 text

@epiloic 50 Resources Blackadder II Blackadder the Third Blackadder goes forth http://gnugat.github.io/micro-framework-bundle/