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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
0
260
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
590
スマートグラスで並列バイブコーディング
hyshu
0
150
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
710
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
240
Datadog × OpenTelemetry 入門と実践のあいだ
kn_to_maxpno
1
160
Vite+ Unified Toolchain for the Web
naokihaba
0
320
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
390
Lessons from Spec-Driven Development
simas
PRO
0
210
AIとASP.NET Coreで雑Webアプリを作った話
mayuki
0
660
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
700
肥大化するレガシーコードに立ち向かうためのインターフェース分離と依存の逆転 / JJUG CCC 2026 Spring
hirokunimaeta
0
570
Featured
See All Featured
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Building AI with AI
inesmontani
PRO
1
1.1k
We Have a Design System, Now What?
morganepeng
55
8.2k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.5k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
590
It's Worth the Effort
3n
188
29k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
370
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.5k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
390
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
200
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
170
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