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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Michael C.
November 16, 2016
Programming
620
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
180
Machine Learning and Trend Analysis in PHP - Cascadia PHP
michaelcullum
0
180
Trend Analysis & Machine Learning in PHP - PHP SW
michaelcullum
0
170
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
ふつうのFeature Flag実践入門
irof
8
4.2k
Datadog × OpenTelemetry 入門と実践のあいだ
kn_to_maxpno
1
180
なぜ型を書くのか? TSKaigi2026で改めて考える #tskaigi_smarthr
kajitack
0
140
軽量Java基盤の設計 DIコンテナに頼らない、長期保守と1秒起動の実現 JJUG CCC 2026 Spring
macha64
0
570
Dataformのリポジトリを立ち上げるときにまずやること / dataform-day0-2026
snhryt
0
180
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
740
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
230
AI時代のUIはどこへ行く?その2!
yusukebe
22
7.5k
エンジニアと一緒にテストコードの設計と実装を改善した話
mototakatsu
0
220
Skillsは効率化、Agentsは"自分の拡張"——Builder時代のエージェント編成(CC Night 2026)
wemra
1
160
TAKTでAI駆動開発の品質を設計する
j5ik2o
7
1.5k
Oxcを導入して開発体験が向上した話
yug1224
4
340
Featured
See All Featured
Why Our Code Smells
bkeepers
PRO
340
58k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Site-Speed That Sticks
csswizardry
13
1.2k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
The Language of Interfaces
destraynor
162
27k
ラッコキーワード サービス紹介資料
rakko
1
3.7M
AI: The stuff that nobody shows you
jnunemaker
PRO
8
730
We Are The Robots
honzajavorek
0
250
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
Everyday Curiosity
cassininazir
0
240
The SEO identity crisis: Don't let AI make you average
varn
0
500
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
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