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
JAWS-UG横浜 #102 AWSサ終供養LT会 成仏できない AWS サービスたち 〜本日、三体供養します〜
maroon1st
0
340
Google Apps Script で Ruby を動かす
kawahara
0
140
AIが無かった頃の素敵な出会いの話
codmoninc
1
390
PHP Application における Kubernetes 内 gRPC 通信
ganchiku
0
590
AI時代のPHPer生存戦略 ~「言語、もうなんでもよくない?」に本気で向き合う~
vivion
0
300
AWS CDK を「作」ってみた 〜フルスクラッチで見えた CDK の裏側〜 / aws-cdk-from-scratch
gotok365
3
2.8k
【SRE NEXT 2026 Lunch Session】一人目専任SREの立ち上げを加速する ― AIと進めたオンボーディングで2分を0.04秒にした話
pkshadeck
PRO
0
3.6k
yield再入門 #phpcon
o0h
PRO
0
980
Claude Code全社展開のためにやったことn選~プラグイン302個・コミッター271人を支えるために~
kenchan
5
1.4k
Lean は証明の正しさを確認するためだけのツールって思ってませんか?
inoueasei
1
150
Terraform標準の組織で AWS CDKをどう使うか
mu7889yoon
1
490
作るコストが小さくなった時代 幸せに働くために改めて考えたいこと 〜エンジニアとして価値を出し続けるために注視している二分野〜
yuppeeng
0
190
Featured
See All Featured
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.3k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.9k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
570
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
460
A Soul's Torment
seathinner
6
3.4k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.7k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.9k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
290
Unsuck your backbone
ammeep
672
58k
Test your architecture with Archunit
thirion
1
2.3k
Technical Leadership for Architectural Decision Making
baasie
3
470
Site-Speed That Sticks
csswizardry
13
1.4k
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