SlideShare ist ein Scribd-Unternehmen logo
1 von 54
Downloaden Sie, um offline zu lesen
#MERIXSTUDIO
#SYMFONY 2
MAKES LIFE EASIER
#WHYILOVESYMFONY2
And why you should too
#COMMUNITY
Knowledge sharing
Kris Wallsmith
Wow, such SymfonyCon
#PROJECTS USING
SYMFONY
◇ Drupal
◇ Composer
◇ Laravel
◇ Shopware
◇ phpBB
◇ Magento
◇ Silex
◇ Codeception
◇ Behat
◇ Thelia
◇ eZ publish
◇ Piwik
#KNOWTHETRICKS
And why you should to
#SMALL TRICKS
◇ composer dump-autoload --optimize
◇ {% do form.name.setRendered %}
◇ debug channels: "!event"
#CONSOLE
MORE:ELEGANT
◇ BEGINNERS WAY
php app/console --env=prod assetic:dump
◇ BETTER WAY
./app/console --env=prod assetic:dump
◇ PROS WAY
prod a:d
◇ Query Cache
◇ Result Cache
◇ Metadata Cache
#QUITE UNCOMFORTABLE
SERIALIZE/DESERIALIZE
HANDLE THE
ASSOCIATIONS
WHEN UPDATE
THE DATA ?
WHEN TO SET UP CACHE IN THE
PROJECT?
to fast?
not now
to late - deadline
#SECOND LEVEL CACHE
Hell has frozen over
WHAT S NEEDED
Redis
Memcached
Apc
doctrine/orm>=2.5.* Database
# Doctrine Configuration
doctrine:
dbal:
...
orm:
...
entity_managers:
default:
second_level_cache:
enabled: true
log_enabled: true
region_cache_driver: redis
filters:
...
#DOCTRINE CONFIGURATION
CACHING MODE
READ_ONLY (DEFAULT)
■ Can do reads,
inserts and
deletes, cannot
perform updates
or employ any
locks.
■ Useful for data
that is read
frequently but
never updated.
■ Best performer.
■ It is Simple.
NONSTRICT_READ_WRITE
■ Read Write Cache
doesn t employ
any locks but can
do reads, inserts,
updates and
deletes.
■ Good if the
application needs
to update data
rarely.
READ_WRITE
■ Read Write cache
employs locks
before
update/delete.
■ Use if data needs
to be updated.
■ Slowest strategy.
■ To use it a the
cache region
implementation
must support
locking.
<?php
/**
* @Entity
*
* @Cache(usage="READ_ONLY", region="my_entity_region")
*
*/
class Country
{
/**
* @Id
* @GeneratedValue
* @Column(type="integer")
*/
protected $id;
/**
* @Column(unique=true)
*/
protected $name;
// other properties and methods
}
#ENTITY
<?php
/**
* @Entity
* @Cache("NONSTRICT_READ_WRITE")
*/
class State
{
/**
* @Id
* @GeneratedValue
* @Column(type="integer")
*/
protected $id;
/**
* @Column(unique=true)
*/
protected $name;
#CACHE ASSOCIATION
/**
* @Cache("NONSTRICT_READ_WRITE")
* @ManyToOne(targetEntity="Country")
* @JoinColumn(name="country_id",
referencedColumnName="id")
*/
protected $country;
/**
* @Cache("NONSTRICT_READ_WRITE")
* @OneToMany(targetEntity="City", mappedBy="state")
*/
protected $cities;
// other properties and methods
}
The most common use case is to cache entities. But we can also cache relationships. It caches the primary keys of association and
cache each element will be cached into its region.
Place your screenshot here
Get insight into the
errors that affect your
customers.
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: grouped_main
sentry:
type: raven
dsn: 'https://<key>:<secret>@app.getsentry.com/<project>'
level: error
# Groups
grouped_main:
type: group
members: [sentry, streamed_main]
# Streams
streamed_main:
type: stream
path: %kernel.logs_dir%/%kernel.environment%.log
level: error
#SENTRY_SYMFONY
#BEST FEATURES
◇ KNOW
IMMEDIATELY IF
SOMETHING GOES
WRONG
◇ SNOZE TIL NEXT
VERSION
◇ SEE THE IMPACT
OF EACH RELEASE
IN REAL-TIME
◇ COLLECT AND
GROUP ERRORS
◇ DIAGNOSE AND FIX
ISSUES FASTER
THAN EVER
◇ NOTIFICATIONS
AND EXTRA
READABLE LOGS
#IS SYMFONY
FAST?
SO PHALCON MAYBE ????
IT S ABOUT TOOLS
#IT S NOT ONLY
PERFORMANCE
#INITIALIZATION TIME
KERNEL.REQUEST.LOADING
//JMSDebuggingBundle
#MORE ABOUT
WEIGHT OF THE
LISTENERS
SYMFONY/COMPONENT/SECURITY/HTTP/FIREWALL
public function vote(Token Interface $token, $object, array $attributes)
// … details: checking if we support this attribute
if(in_array(‘ROLE_SUPER_ADMIN’, $oken->getRoles())){
return self::ACCESS_GRANTED;
}
//get the user, force to null if we’re anonymous
$user = ($token->getUser() instanceof User) ? $token->getUser() : null;
if($object->getOwner() && $object->getOwner() == $user) {
return self::ACCESS_GRANTED;
}
return VoterInterface::ACCESS_DENIED;
}
#CUSTOM VOTER
◇ SEPARATED BUSINESS LOGIC !!!
◇ NOT USING ACL :))
◇ EASY TO UNIT TESTS
◇ SIMPLE ! AND REUSABLE !
#WHY TO DO THAT
$sc->isGranted( EDIT , $blog )
SPOOLING EMAILS
SPOOL IN MEMORY
swiftmailer:
# ...
spool: { type:
memory }
SPOOL USING FILES
swiftmailer:
# ...
spool:
type: file
path:
/path/to/spooldir
TIME LIMIT
php bin/console swiftmailer:
spool:send --time-limit=10 --
env=prod
MESSAGE LIMIT
php bin/console
swiftmailer:spool:send --
message-limit=10 --env=prod
PRIORITIZED EMAILS
HIGH-PRIORITY EMAILS
$container->get('swiftmailer.mailer.instant)->...
REGULAR EMAILS
$container->get('swiftmailer.mailer')->...
$container->get('swiftmailer.mailer.delayed')->...
#STILL TO SLOW?
#DUMMY HELLO TEST
~6-18ms
With it
~40-50ms
Without
#PHP PROCES MANAGER
PHP-PM
...is a process manager, supercharger and load balancer for
PHP applications.
It's based on ReactPHP and works best with applications that
use request-response frameworks like Symfony's HTTPKernel.
The approach of this is to kill the expensive bootstrap of PHP
(declaring symbols, loading/parsing files) and the bootstrap of
feature-rich frameworks. See Performance section for a quick
hint. PHP-PM basically spawns several PHP instances as
worker bootstraping your application (eg. the whole Symfony
Kernel) and hold it in the memory to be prepared for every
incoming request: This is why PHP-PM makes your application
so fast.
# change minimum-stability to dev in your composer.json (until
we have a version tagged): "minimum-stability": "dev"
composer require php-pm/php-pm:dev-master
composer require php-pm/httpkernel-adapter:
dev-master #if you have httpkernel (laravel,
symfony)
./vendor/bin/ppm config --bootstrap=symfony
#places a ppm.json in your directory
./vendor/bin/ppm start
#reads ppm.json and starts the server like
you want
#INSTALLATION
There will be a memory leak !
Fabpot is working on it.
"bridge": "HttpKernel",
"host": "127.0.0.1",
"port": 8001,
"workers": 8,
"app-env": "dev",
"debug": 1,
"logging": 1,
"static": true,
"bootstrap": "symfony",
"max-requests": 1000,
"concurrent-requests": false,
"php-cgi": false
#CONFIGURATION
#LET S USE IT AS A
DEV SERVER
Server Software:
Server Hostname: localhost
Server Port: 8001
Document Path: /
Document Length: 26037 bytes
Concurrency Level: 10
Time taken for tests: 133.327 seconds
Complete requests: 5000
Failed requests: 0
Total transferred: 131720000 bytes
HTML transferred: 130185000 bytes
Requests per second: 37.50 [#/sec] (mean)
Time per request: 266.654 [ms] (mean)
Time per request: 26.665 [ms] (mean, across all concurrent requests)
Transfer rate: 964.79 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 1
Processing: 235 266 7.2 265 469
Waiting: 219 260 7.2 259 463
Total: 236 266 7.2 265 469
dev s:start localhost:8001
Server Software:
Server Hostname: localhost
Server Port: 8001
Document Path: /
Document Length: 26050 bytes
Concurrency Level: 10
Time taken for tests: 12.233 seconds
Complete requests: 5000
Failed requests: 0
Total transferred: 131255000 bytes
HTML transferred: 130250000 bytes
Requests per second: 408.72 [#/sec] (mean)
Time per request: 24.466 [ms] (mean)
Time per request: 2.447 [ms] (mean, across all concurrent requests)
Transfer rate: 10477.97 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 10 24 15.1 23 524
Waiting: 7 22 14.9 20 519
Total: 10 24 15.1 23 524
./vendor/bin/ppm start
~11 % ??
Whoa! That’s a big number, aren’t
you proud?
~11 X !!!
Whoa! That’s a big number, aren’t
you proud?
Nope
#PHPFastCGI
PHPFastCGI
…is a collection of libraries that can be used to build FastCGI
applications in PHP. Unlike normal PHP applications, these
applications can stay alive between request cycles - improving
speed and lowering resource use. is a process manager,
supercharger and load balancer for PHP applications
Speedfony Bundle.
A symfony2 bundle which allows applications to reduce
overheads by exposing symfony's Request-Response structure
to a FastCGI daemon.
BUT
STILL NOT STABLE
composer require "phpfastcgi/speedfony-bundle:^0.8"
// app/AppKernel.php
// ...
new PHPFastCGISpeedfonyBundlePHPFastCGISpeedfonyBundle(),
php app/console speedfony:run --port 5000 --env="prod"
Conclusion
There is lots to be gained and lots to be
lost by daemonizing your PHP
applications. It is very important that
you are aware of the potential issues
you could face and how to mitigate
these. However, with a properly
designed and carefully considered
application - you can reach response
speeds well beyond the dreaming limits
of conventional PHP applications.
ANY QUESTIONS?
You can find me at
a.klimczyk@merixstudio.com
SOURCES
This presentations uses the following sources:
◇ http://www.slideshare.net/javier.eguiluz/symfony-tips-and-tricks
◇ http://doctrine-orm.readthedocs.org/projects/doctrine-
orm/en/latest/reference/second-level-cache.html
◇ https://www.youtube.com/watch?
v=DuWtvjQCoZk&index=1&list=PLo7mBDsRHu12dJVHaL2Eu5qDUu
oe6xq_5
◇ http://espeo.eu/blog/is-phalcon-really-so-good/
◇ https://www.youtube.com/watch?
v=DuWtvjQCoZk&index=1&list=PLo7mBDsRHu12dJVHaL2Eu5qDUu
oe6xq_5

Weitere ähnliche Inhalte

Was ist angesagt?

Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability Systems
Marcelo Pinheiro
 

Was ist angesagt? (20)

Tips and Tricks for your Service Oriented Architecture @ CakeFest 2013 in San...
Tips and Tricks for your Service Oriented Architecture @ CakeFest 2013 in San...Tips and Tricks for your Service Oriented Architecture @ CakeFest 2013 in San...
Tips and Tricks for your Service Oriented Architecture @ CakeFest 2013 in San...
 
The Integration of Laravel with Swoole
The Integration of Laravel with SwooleThe Integration of Laravel with Swoole
The Integration of Laravel with Swoole
 
Gearman
GearmanGearman
Gearman
 
Running and Scaling Magento on AWS
Running and Scaling Magento on AWSRunning and Scaling Magento on AWS
Running and Scaling Magento on AWS
 
Forensic Tools for In-Depth Performance Investigations
Forensic Tools for In-Depth Performance InvestigationsForensic Tools for In-Depth Performance Investigations
Forensic Tools for In-Depth Performance Investigations
 
Namshi in 2014: let's rock!
Namshi in 2014: let's rock!Namshi in 2014: let's rock!
Namshi in 2014: let's rock!
 
A Docker-based Development Environment Even I Can Understand
A Docker-based Development Environment Even I Can UnderstandA Docker-based Development Environment Even I Can Understand
A Docker-based Development Environment Even I Can Understand
 
IaC and Immutable Infrastructure with Terraform, Сергей Марченко
IaC and Immutable Infrastructure with Terraform, Сергей МарченкоIaC and Immutable Infrastructure with Terraform, Сергей Марченко
IaC and Immutable Infrastructure with Terraform, Сергей Марченко
 
A few words about WAMP
A few words about WAMPA few words about WAMP
A few words about WAMP
 
Zendcon magento101
Zendcon magento101Zendcon magento101
Zendcon magento101
 
Converting Your DEV Environment to a Docker Stack
Converting Your DEV Environment to a Docker StackConverting Your DEV Environment to a Docker Stack
Converting Your DEV Environment to a Docker Stack
 
Converting your DEV Environment to a Docker Stack - ZCOE18
Converting your DEV Environment to a Docker Stack - ZCOE18Converting your DEV Environment to a Docker Stack - ZCOE18
Converting your DEV Environment to a Docker Stack - ZCOE18
 
A complete guide to Node.js
A complete guide to Node.jsA complete guide to Node.js
A complete guide to Node.js
 
Scaling Your App With Docker Swarm using Terraform, Packer on Openstack
Scaling Your App With Docker Swarm using Terraform, Packer on OpenstackScaling Your App With Docker Swarm using Terraform, Packer on Openstack
Scaling Your App With Docker Swarm using Terraform, Packer on Openstack
 
High-Performance Magento in the Cloud
High-Performance Magento in the CloudHigh-Performance Magento in the Cloud
High-Performance Magento in the Cloud
 
Php Dependency Management with Composer ZendCon 2016
Php Dependency Management with Composer ZendCon 2016Php Dependency Management with Composer ZendCon 2016
Php Dependency Management with Composer ZendCon 2016
 
Gearman and asynchronous processing in PHP applications
Gearman and asynchronous processing in PHP applicationsGearman and asynchronous processing in PHP applications
Gearman and asynchronous processing in PHP applications
 
About Node.js
About Node.jsAbout Node.js
About Node.js
 
Performance tips for Symfony2 & PHP
Performance tips for Symfony2 & PHPPerformance tips for Symfony2 & PHP
Performance tips for Symfony2 & PHP
 
Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability Systems
 

Ähnlich wie Why we choose Symfony2

Php Inside - confoo 2011 - Derick Rethans
Php Inside -  confoo 2011 - Derick RethansPhp Inside -  confoo 2011 - Derick Rethans
Php Inside - confoo 2011 - Derick Rethans
Bachkoutou Toutou
 
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
Fabien Potencier
 
Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11
Combell NV
 

Ähnlich wie Why we choose Symfony2 (20)

Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / Webgrind
 
ZendCon 2015 - DevOps for Small Teams
ZendCon 2015 - DevOps for Small TeamsZendCon 2015 - DevOps for Small Teams
ZendCon 2015 - DevOps for Small Teams
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
 
Php Inside - confoo 2011 - Derick Rethans
Php Inside -  confoo 2011 - Derick RethansPhp Inside -  confoo 2011 - Derick Rethans
Php Inside - confoo 2011 - Derick Rethans
 
Developer-Friendly CI / CD for Kubernetes
Developer-Friendly CI / CD for KubernetesDeveloper-Friendly CI / CD for Kubernetes
Developer-Friendly CI / CD for Kubernetes
 
Mazda siv - web services
Mazda   siv - web servicesMazda   siv - web services
Mazda siv - web services
 
Midwest PHP 2017 DevOps For Small team
Midwest PHP 2017 DevOps For Small teamMidwest PHP 2017 DevOps For Small team
Midwest PHP 2017 DevOps For Small team
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.js
 
PHP on Heroku: Deploying and Scaling Apps in the Cloud
PHP on Heroku: Deploying and Scaling Apps in the CloudPHP on Heroku: Deploying and Scaling Apps in the Cloud
PHP on Heroku: Deploying and Scaling Apps in the Cloud
 
TIAD - DYI: A simple orchestrator built step by step
TIAD - DYI: A simple orchestrator built step by stepTIAD - DYI: A simple orchestrator built step by step
TIAD - DYI: A simple orchestrator built step by step
 
Scaleable PHP Applications in Kubernetes
Scaleable PHP Applications in KubernetesScaleable PHP Applications in Kubernetes
Scaleable PHP Applications in Kubernetes
 
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
 
DevOps For Small Teams
DevOps For Small TeamsDevOps For Small Teams
DevOps For Small Teams
 
Scaling PHP apps
Scaling PHP appsScaling PHP apps
Scaling PHP apps
 
Comment améliorer le quotidien des Développeurs PHP ?
Comment améliorer le quotidien des Développeurs PHP ?Comment améliorer le quotidien des Développeurs PHP ?
Comment améliorer le quotidien des Développeurs PHP ?
 
Your Inner Sysadmin - MidwestPHP 2015
Your Inner Sysadmin - MidwestPHP 2015Your Inner Sysadmin - MidwestPHP 2015
Your Inner Sysadmin - MidwestPHP 2015
 
Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
 
Ran Mizrahi - Symfony2 meets Drupal8
Ran Mizrahi - Symfony2 meets Drupal8Ran Mizrahi - Symfony2 meets Drupal8
Ran Mizrahi - Symfony2 meets Drupal8
 
Kubernetes laravel and kubernetes
Kubernetes   laravel and kubernetesKubernetes   laravel and kubernetes
Kubernetes laravel and kubernetes
 

Mehr von Merixstudio

Mehr von Merixstudio (7)

Jak przeżyć "kreatywne" warsztaty online i nie zwariować
Jak przeżyć "kreatywne" warsztaty online i nie zwariowaćJak przeżyć "kreatywne" warsztaty online i nie zwariować
Jak przeżyć "kreatywne" warsztaty online i nie zwariować
 
Introduction to BEM Methodology
Introduction to BEM MethodologyIntroduction to BEM Methodology
Introduction to BEM Methodology
 
gamifikacja
gamifikacjagamifikacja
gamifikacja
 
Design Thinking 101
Design Thinking 101Design Thinking 101
Design Thinking 101
 
Magento - wprowadzenie
Magento - wprowadzenieMagento - wprowadzenie
Magento - wprowadzenie
 
Responsive Web Design: why is it so crucial?
Responsive Web Design: why is it so crucial?Responsive Web Design: why is it so crucial?
Responsive Web Design: why is it so crucial?
 
Merixstudio: about us
Merixstudio: about usMerixstudio: about us
Merixstudio: about us
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

Why we choose Symfony2

  • 2.
  • 3.
  • 6.
  • 9.
  • 10. #PROJECTS USING SYMFONY ◇ Drupal ◇ Composer ◇ Laravel ◇ Shopware ◇ phpBB ◇ Magento ◇ Silex ◇ Codeception ◇ Behat ◇ Thelia ◇ eZ publish ◇ Piwik
  • 12. #SMALL TRICKS ◇ composer dump-autoload --optimize ◇ {% do form.name.setRendered %} ◇ debug channels: "!event"
  • 13. #CONSOLE MORE:ELEGANT ◇ BEGINNERS WAY php app/console --env=prod assetic:dump ◇ BETTER WAY ./app/console --env=prod assetic:dump ◇ PROS WAY prod a:d
  • 14. ◇ Query Cache ◇ Result Cache ◇ Metadata Cache
  • 16. WHEN TO SET UP CACHE IN THE PROJECT? to fast? not now to late - deadline
  • 17. #SECOND LEVEL CACHE Hell has frozen over
  • 19. # Doctrine Configuration doctrine: dbal: ... orm: ... entity_managers: default: second_level_cache: enabled: true log_enabled: true region_cache_driver: redis filters: ... #DOCTRINE CONFIGURATION
  • 20. CACHING MODE READ_ONLY (DEFAULT) ■ Can do reads, inserts and deletes, cannot perform updates or employ any locks. ■ Useful for data that is read frequently but never updated. ■ Best performer. ■ It is Simple. NONSTRICT_READ_WRITE ■ Read Write Cache doesn t employ any locks but can do reads, inserts, updates and deletes. ■ Good if the application needs to update data rarely. READ_WRITE ■ Read Write cache employs locks before update/delete. ■ Use if data needs to be updated. ■ Slowest strategy. ■ To use it a the cache region implementation must support locking.
  • 21. <?php /** * @Entity * * @Cache(usage="READ_ONLY", region="my_entity_region") * */ class Country { /** * @Id * @GeneratedValue * @Column(type="integer") */ protected $id; /** * @Column(unique=true) */ protected $name; // other properties and methods } #ENTITY
  • 22. <?php /** * @Entity * @Cache("NONSTRICT_READ_WRITE") */ class State { /** * @Id * @GeneratedValue * @Column(type="integer") */ protected $id; /** * @Column(unique=true) */ protected $name; #CACHE ASSOCIATION /** * @Cache("NONSTRICT_READ_WRITE") * @ManyToOne(targetEntity="Country") * @JoinColumn(name="country_id", referencedColumnName="id") */ protected $country; /** * @Cache("NONSTRICT_READ_WRITE") * @OneToMany(targetEntity="City", mappedBy="state") */ protected $cities; // other properties and methods } The most common use case is to cache entities. But we can also cache relationships. It caches the primary keys of association and cache each element will be cached into its region.
  • 23. Place your screenshot here Get insight into the errors that affect your customers.
  • 24. monolog: handlers: main: type: fingers_crossed action_level: error handler: grouped_main sentry: type: raven dsn: 'https://<key>:<secret>@app.getsentry.com/<project>' level: error # Groups grouped_main: type: group members: [sentry, streamed_main] # Streams streamed_main: type: stream path: %kernel.logs_dir%/%kernel.environment%.log level: error #SENTRY_SYMFONY
  • 25. #BEST FEATURES ◇ KNOW IMMEDIATELY IF SOMETHING GOES WRONG ◇ SNOZE TIL NEXT VERSION ◇ SEE THE IMPACT OF EACH RELEASE IN REAL-TIME ◇ COLLECT AND GROUP ERRORS ◇ DIAGNOSE AND FIX ISSUES FASTER THAN EVER ◇ NOTIFICATIONS AND EXTRA READABLE LOGS
  • 28. IT S ABOUT TOOLS #IT S NOT ONLY PERFORMANCE
  • 32. public function vote(Token Interface $token, $object, array $attributes) // … details: checking if we support this attribute if(in_array(‘ROLE_SUPER_ADMIN’, $oken->getRoles())){ return self::ACCESS_GRANTED; } //get the user, force to null if we’re anonymous $user = ($token->getUser() instanceof User) ? $token->getUser() : null; if($object->getOwner() && $object->getOwner() == $user) { return self::ACCESS_GRANTED; } return VoterInterface::ACCESS_DENIED; } #CUSTOM VOTER
  • 33. ◇ SEPARATED BUSINESS LOGIC !!! ◇ NOT USING ACL :)) ◇ EASY TO UNIT TESTS ◇ SIMPLE ! AND REUSABLE ! #WHY TO DO THAT
  • 35. SPOOLING EMAILS SPOOL IN MEMORY swiftmailer: # ... spool: { type: memory } SPOOL USING FILES swiftmailer: # ... spool: type: file path: /path/to/spooldir TIME LIMIT php bin/console swiftmailer: spool:send --time-limit=10 -- env=prod MESSAGE LIMIT php bin/console swiftmailer:spool:send -- message-limit=10 --env=prod
  • 36. PRIORITIZED EMAILS HIGH-PRIORITY EMAILS $container->get('swiftmailer.mailer.instant)->... REGULAR EMAILS $container->get('swiftmailer.mailer')->... $container->get('swiftmailer.mailer.delayed')->...
  • 38. #DUMMY HELLO TEST ~6-18ms With it ~40-50ms Without
  • 40. PHP-PM ...is a process manager, supercharger and load balancer for PHP applications. It's based on ReactPHP and works best with applications that use request-response frameworks like Symfony's HTTPKernel. The approach of this is to kill the expensive bootstrap of PHP (declaring symbols, loading/parsing files) and the bootstrap of feature-rich frameworks. See Performance section for a quick hint. PHP-PM basically spawns several PHP instances as worker bootstraping your application (eg. the whole Symfony Kernel) and hold it in the memory to be prepared for every incoming request: This is why PHP-PM makes your application so fast.
  • 41. # change minimum-stability to dev in your composer.json (until we have a version tagged): "minimum-stability": "dev" composer require php-pm/php-pm:dev-master composer require php-pm/httpkernel-adapter: dev-master #if you have httpkernel (laravel, symfony) ./vendor/bin/ppm config --bootstrap=symfony #places a ppm.json in your directory ./vendor/bin/ppm start #reads ppm.json and starts the server like you want #INSTALLATION
  • 42. There will be a memory leak ! Fabpot is working on it.
  • 43. "bridge": "HttpKernel", "host": "127.0.0.1", "port": 8001, "workers": 8, "app-env": "dev", "debug": 1, "logging": 1, "static": true, "bootstrap": "symfony", "max-requests": 1000, "concurrent-requests": false, "php-cgi": false #CONFIGURATION
  • 44. #LET S USE IT AS A DEV SERVER
  • 45. Server Software: Server Hostname: localhost Server Port: 8001 Document Path: / Document Length: 26037 bytes Concurrency Level: 10 Time taken for tests: 133.327 seconds Complete requests: 5000 Failed requests: 0 Total transferred: 131720000 bytes HTML transferred: 130185000 bytes Requests per second: 37.50 [#/sec] (mean) Time per request: 266.654 [ms] (mean) Time per request: 26.665 [ms] (mean, across all concurrent requests) Transfer rate: 964.79 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.0 0 1 Processing: 235 266 7.2 265 469 Waiting: 219 260 7.2 259 463 Total: 236 266 7.2 265 469 dev s:start localhost:8001
  • 46. Server Software: Server Hostname: localhost Server Port: 8001 Document Path: / Document Length: 26050 bytes Concurrency Level: 10 Time taken for tests: 12.233 seconds Complete requests: 5000 Failed requests: 0 Total transferred: 131255000 bytes HTML transferred: 130250000 bytes Requests per second: 408.72 [#/sec] (mean) Time per request: 24.466 [ms] (mean) Time per request: 2.447 [ms] (mean, across all concurrent requests) Transfer rate: 10477.97 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.0 0 0 Processing: 10 24 15.1 23 524 Waiting: 7 22 14.9 20 519 Total: 10 24 15.1 23 524 ./vendor/bin/ppm start
  • 47. ~11 % ?? Whoa! That’s a big number, aren’t you proud?
  • 48. ~11 X !!! Whoa! That’s a big number, aren’t you proud? Nope
  • 50. PHPFastCGI …is a collection of libraries that can be used to build FastCGI applications in PHP. Unlike normal PHP applications, these applications can stay alive between request cycles - improving speed and lowering resource use. is a process manager, supercharger and load balancer for PHP applications Speedfony Bundle. A symfony2 bundle which allows applications to reduce overheads by exposing symfony's Request-Response structure to a FastCGI daemon.
  • 51. BUT STILL NOT STABLE composer require "phpfastcgi/speedfony-bundle:^0.8" // app/AppKernel.php // ... new PHPFastCGISpeedfonyBundlePHPFastCGISpeedfonyBundle(), php app/console speedfony:run --port 5000 --env="prod"
  • 52. Conclusion There is lots to be gained and lots to be lost by daemonizing your PHP applications. It is very important that you are aware of the potential issues you could face and how to mitigate these. However, with a properly designed and carefully considered application - you can reach response speeds well beyond the dreaming limits of conventional PHP applications.
  • 53. ANY QUESTIONS? You can find me at a.klimczyk@merixstudio.com
  • 54. SOURCES This presentations uses the following sources: ◇ http://www.slideshare.net/javier.eguiluz/symfony-tips-and-tricks ◇ http://doctrine-orm.readthedocs.org/projects/doctrine- orm/en/latest/reference/second-level-cache.html ◇ https://www.youtube.com/watch? v=DuWtvjQCoZk&index=1&list=PLo7mBDsRHu12dJVHaL2Eu5qDUu oe6xq_5 ◇ http://espeo.eu/blog/is-phalcon-really-so-good/ ◇ https://www.youtube.com/watch? v=DuWtvjQCoZk&index=1&list=PLo7mBDsRHu12dJVHaL2Eu5qDUu oe6xq_5