Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Silex versus Symfony, Microframework vs full-stack
Search
Michael C.
November 16, 2016
Programming
630
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Silex versus Symfony, Microframework vs full-stack
Michael C.
November 16, 2016
More Decks by Michael C.
See All by Michael C.
OOP & Design Patterns (Part 1 + Part 2)
michaelcullum
0
680
Building a first class REST API with Symfony
michaelcullum
3
2.1k
Trend Analysis and Machine Learning in PHP - PHP South Africa
michaelcullum
0
240
Hadoop & PHP - PHP South Africa
michaelcullum
0
190
Machine Learning and Trend Analysis in PHP - Cascadia PHP
michaelcullum
0
190
Trend Analysis & Machine Learning in PHP - PHP SW
michaelcullum
0
180
Machine Learning and Trend Analysis in PHP - DPC 18
michaelcullum
0
330
Trend Analysis & Machine Learning in PHP - PHP Serbia
michaelcullum
1
410
Machine Learning and Trend Analysis in PHP - DevDays Vilnius
michaelcullum
1
180
Other Decks in Programming
See All in Programming
Prismを使った型安全な暗号化_関数型まつり2026
_fhhmm
0
170
React本体のコードリーディング
high_g_engineer
1
130
『コードを書く以外の』エンジニアリング〜課金基盤移行プロジェクト推進のためのTips4選
yuriko1211
0
570
Apache Hive: そしてCloud Native Lakehouseへ
okumin
1
200
TSX の <Hoge<Fuga>> という構文に驚いた話 / tsx-type-argument-syntax
kanaru0928
0
200
Claude Team Plan導入・ガイド
tk3fftk
0
250
ルールを書いて終わらせないハーネスエンジニアリング
yug1224
4
1.8k
ドリフトを絶対に許さない(?)CDK運用 / CDK Ops with Zero Tolerance for Drifts (?)
akihisaikeda
1
170
生成AIで帳票OCRが「簡単に」作れる時代になった?
kon_shou
0
390
Embedded SREと共に達成した会員管理システムのAWS移行 - SRE NEXT 2026 ランチスポンサーセッション
niftycorp
PRO
1
3.4k
Google Apps Script で Ruby を動かす
kawahara
0
130
作るコストが小さくなった時代 幸せに働くために改めて考えたいこと 〜エンジニアとして価値を出し続けるために注視している二分野〜
yuppeeng
0
180
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Automating Front-end Workflow
addyosmani
1370
210k
Producing Creativity
orderedlist
PRO
348
40k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
450
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
67
56k
Deep Space Network (abreviated)
tonyrice
0
250
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2.1k
Rails Girls Zürich Keynote
gr2m
96
14k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
610
Color Theory Basics | Prateek | Gurzu
gurzu
0
410
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Transcript
SILEX VS SYMFONY THE FINAL SHOWDOWN PHP[WORLD] 2016 @MICHAELCULLUMUK
ME?
MICHAEL CULLUM @MICHAELCULLUMUK
SYMFONY
SYMFONY COMPONENTS
SYMFONY/ SYMFONY-STANDARD
COMPONENT BASED
USES COMPONENTS
SILEX
SILEX
HELLO WORLD
SILEX <?php require_once __DIR__.'/../vendor/autoload.php'; $app = new Silex\Application(); $app->get('/hello/{name}', function
($name) use ($app) { return 'Hello '.$app->escape($name); }); $app->run();
SYMFONY CONTROLLER <?php namespace Acme\HelloBundle\Controller; use Symfony\Component\HttpFoundation\Response; class HelloController {
public function indexAction($name) { return new Response('<html><body>Hello '.$name.'!</body></html>'); } }
SYMFONY CONFIGURATION <?php public function registerBundles() { $bundles = array(
// ... new Acme\HelloBundle\AcmeHelloBundle(), ); return $bundles; } php app/console generate:bundle --namespace=Acme/HelloBundle --format=yml _hello: pattern: /hello/{name} defaults: { _controller: AcmeHelloBundle:Hello:index }
BENCHMARKING VMWare Fusion: Ubuntu 64-bit Server 15.04 NGINX PHP 5.6.4
2GB RAM 4 cores (Intel Core i7, 3.4 GHz). Requests per second: 551.59 Time per request: 1.813ms Requests per second: 1424.30 Time per request: 0.702ms 0 375 750 1125 1500 SYMFONY SILEX
HELLO WORLD
ROUTES
HELLO WORLD * 100
BENCHMARKING 0 0.03 0.06 0.09 0.12 SYMFONY SILEX
CONTAINER
SERVICE CONTAINER DUMPING
BENCHMARKING Source: Igor Wiedler Memory Usage: 931K Wall time: 6.124ms
Memory Usage: 579K Wall time: 0.86ms Memory Usage: 738K Wall time: 0.495ms Dumped
BENCHMARKING 0 250 500 750 1000 SYMFONY SYMFONY (DUMPED) PIMPLE
0 1.75 3.5 5.25 7 SYMFONY SYMFONY (DUMPED) PIMPLE Memory (K) Wall time (ms)
BENCHMARKING 0 200 400 600 800 SYMFONY (DUMPED) PIMPLE 0
0.225 0.45 0.675 0.9 SYMFONY (DUMPED) PIMPLE Memory (K) Wall time (ms)
MAINTAINABILITY
LESS AVAILABLE
STRUCTURE
SHORTCUTS & MAGIC
APIS
FORMS
AUTHENTICATION
RATE LIMITING
LARGE APPLICATIONS
LOSS OF PERFORMANCE GAINS
BUSINESS LOGIC
YAML
TIDYING UP SILEX
MINIMAL FRONT CONTROLLER
RAD - 5 ROUTES
FRONT CONTROLLER <?php require_once __DIR__.'/../vendor/autoload.php'; use Silex\Application; use Michaelcullum\Router; include
__DIR__.'/config.php'; // Basic App Setup Stuff $app = new Application(); $router = new Router($app); // Register service providers include __DIR__.'/../src/Michaelcullum/registerProviders.php'; // Set twig layout template $app->before(function () use ($app) { $app['twig']->addGlobal('layout', $app['twig']->loadTemplate('base.html.twig')); }); $app->mount('/', $router->setBasicRoutes()); $app->run();
CONTROLLERS
CONTROLLERS <?php namespace Michaelcullum\Controller; use Silex\Application; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Validator\Constraints
as Assert; class FooController { public function contactAction(Request $request, Application $app) { return $app['twig']->render('contact.html.twig', []); } }
FORMS $form = $app['form.factory']->createBuilder('form') ->add('name', 'text', array( 'required' => true,
'constraints' => array(new Assert\NotBlank(), new Assert\Length(array('min' => 5))) )) ->getForm(); if ('POST' == $request->getMethod()) { $form->bind($request); if ($form->isValid()) { $data = $form->getData(); return $app['twig']->render('contact.html.twig', []); } }
ROUTING
ROUTING <?php namespace Michaelcullum; use Silex\Application; use Symfony\Component\HttpFoundation\Request; class Router
{ public $app; function __construct(Application $app) { $this->app = $app; } public function setBasicRoutes() { $controllerFactory = $this->app['controllers_factory']; $controllerFactory->get('/', 'Michaelcullum\Controller\BasicPages::indexAction'); $controllerFactory->get('/who', 'Michaelcullum\Controller\BasicPages::whoAction'); return $controllerFactory; } }
PROVIDERS
PROVIDERS <?php use Silex\Provider\FormServiceProvider; use Silex\Provider\TwigServiceProvider; use Silex\Provider\DoctrineServiceProvider; use Symfony\Component\Validator\Constraints
as Assert; use Silex\Provider\ValidatorServiceProvider; use Silex\Provider\TranslationServiceProvider; $app->register(new FormServiceProvider()); $app->register(new ValidatorServiceProvider()); $app->register(new TranslationServiceProvider(), array( 'translator.messages' => array(), )); $app->register(new TwigServiceProvider(), array( 'twig.path' => __DIR__.'/../../views', )); $app->register(new DoctrineServiceProvider(), array( 'dbs.options' => array(array( 'driver' => 'pdo_mysql', 'host' => 'localhost', 'dbname' => getenv('DB_NAME'), 'user' => getenv('DB_USER'), 'password' => getenv('DB_PASSWORD'), 'charset' => 'utf8', )), ));
PROVIDERS VERSUS BUNDLES
REGISTERING SERVICES ON A CONTAINER
PIMPLE
LESS AVAILABLE
DOCTRINE ORM
JUST THE GLUE
WHAT SILEX DOESN’T DO
CONSOLE
ANNOTATIONS
A LOT OF CODE
ANTI-PERFORMANCE
QUESTIONS? @MICHAELCULLUMUK
THANKS @MICHAELCULLUMUK
BIT.LY/WORLD16-SILEX @MICHAELCULLUMUK
2016 2016
SILEX VS SYMFONY THE FINAL SHOWDOWN PHP[WORLD] 2016 @MICHAELCULLUMUK