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

Symfony Nano Framework, a cunning plan

Symfony Nano Framework, a cunning plan

All frameworks seem to have their own micro framework: Zend framework has Expressive, Laravel has Lumen. But what does Symfony have? Silex? MicroKernelTrait? Hah! The stuff's as boring as a pacifist pistol. But don't worry, for I have a plan as cunning as a fox who's just been appointed Professor of Cunning at Oxford University.

Loïc Faugeron

May 15, 2017
Tweet

More Decks by Loïc Faugeron

Other Decks in Technology

Transcript

  1. 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
  2. 1. Micro Framework? 2. Standard Edition 3. Symfony Flex 4.

    Empty Edition 5. Micro Framework Bundle
  3. @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
  4. @epiloic 19 <?php // src/AppBundle/Controller/DefaultController.php namespace AppBundle\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use

    Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; class DefaultController extends Controller { /** * @Route("/", name="homepage") */ public function indexAction(Request $request) { return new Response('Hello World'); } }
  5. @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
  6. @epiloic 21 Results • API: 1 step to add new

    route • Dependencies: 85 (34 + 51) • Footprint: 400 req / s
  7. @epiloic 26 <?php // src/Controller/HelloController.php namespace App\Controller; use Symfony\Component\HttpFoundation\Request; use

    Symfony\Component\HttpFoundation\Response; class HelloController { public function world(Request $request) { return new Response('Hello World'); } }
  8. @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
  9. @epiloic 29 Results • API: 2 steps to add new

    route [+1] • Dependencies: 28 [/3] • Footprint: 950 req / s [x2.5]
  10. @epiloic 34 <?php // src/AppBundle/Controller/HelloController.php namespace AppBundle\Controller; use Symfony\Component\HttpFoundation\Request; use

    Symfony\Component\HttpFoundation\Response; class HelloController { public function world(Request $request) { return new Response('Hello World'); } }
  11. @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
  12. @epiloic 38 Results • API: 3 steps to add new

    route [+1] • Dependencies: 25 [/1.1] • Footprint: 1 000 req / s [x1.1]
  13. @epiloic 43 <?php // app/AppKernel.php use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; class

    AppKernel extends Kernel { public function registerBundles() { return array( new Gnugat\MicroFrameworkBundle\GnugatMicroFrameworkBundle(), new AppBundle\AppBundle(), ); } // ... }
  14. @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
  15. @epiloic 47 Results • API: 3 steps to add new

    route [0] • Dependencies: 16 [/1.5] • Footprint: 1 200 req / s [x1.2]
  16. @epiloic 50 Resources Blackadder II Blackadder the Third Blackadder goes

    forth http://gnugat.github.io/micro-framework-bundle/