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
【やさしく解説 設計編・中級 #4】ルールの寿命と、システムの年輪
panda728
PRO
2
180
20260722_microCMSで考える、AI時代のコンテンツ運用設計
yosh1
0
380
その節約、円になってますか?
isamumumu
1
710
テーブルをDELETEした
yuzneri
0
140
PHP Application における Kubernetes 内 gRPC 通信
ganchiku
0
590
生成AI導入の「期待外れ」を乗り越える ー 開発フロー改革が目指す、真の組織変革
starfish719
0
4.1k
AI時代、エンジニアはどう育つのか -未経験エンジニアの成長を間近で見て考えたこと-
thasu0123
0
220
型も通る、synthも通る、それでも危ない 〜AIのCDKの権限とコストを機械で検証する〜 / It Passes Type Checks, It Passes Synth Checks, but It’s Still Risky — Automatically Verifying Permissions and Costs in AI’s CDK —
seike460
PRO
1
540
5分で問診!Composer セキュリティ健康診断
codmoninc
0
910
AWS CDK を「作」ってみた 〜フルスクラッチで見えた CDK の裏側〜 / aws-cdk-from-scratch
gotok365
3
2.8k
torikago - Ruby::Boxで照らすモジュラモノリスの実行境界
se4weed
1
350
2年かけて Deno に DOMMatrix を実装した話 / How I implemented DOMMatrix in Deno over two years
petamoriken
0
210
Featured
See All Featured
How Software Deployment tools have changed in the past 20 years
geshan
1
34k
Ethics towards AI in product and experience design
skipperchong
2
340
The agentic SEO stack - context over prompts
schlessera
0
860
From π to Pie charts
rasagy
0
260
For a Future-Friendly Web
brad_frost
183
10k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.1k
Statistics for Hackers
jakevdp
799
230k
Navigating Weather and Climate Data
rabernat
0
460
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.4k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.3k
Chasing Engaging Ingredients in Design
codingconduct
0
260
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
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