SlideShare a Scribd company logo
PHP under the hood
Frank Neff
PHP
is
compiled
at
runtime!
Source code you write...
…OpCodes you run
Kidding me?
Looks confusing, but this is...
● how PHP works
● cool for debugging purposes
● visualizing code complexity
● helpful trying to understand opcaches like
APC
Try it with your code
http://explain.php.net.so
So this is about profiling?
No! XHProf is about profiling
● XHProf is a function-level hierarchical
profiler for PHP
● Reports timing information for every function
called
● C-Extension can be loaded via PECL
● GUI and libs available
Looks like this
Try it with your code
http://xhprof.io/
Php under the_hood
Compiling at runtime is slow!
OpCode Cache
● Performance enhancing extension for PHP
● Hooking into the execution life-cycle
● Caching the results of the compilation phase
for later reuse
● APC
● XCache
HHVM
● HipHop Virtual Machine
● Designed for executing PHP programs
● Predecessor HPHPc makes C out of PHP
● Uses a just-in-time (JIT) compilation
● http://www.hhvm.com/
Php under the_hood
LetsTalkAboutNamespaces
Php under the_hood
Kidding me?
No!
● Namespaces in PHP are just class-prefixes
● They are added to each classname by the
compiler
● The result is called a FQCN - Fully Qualified
Class Name
Php under the_hood
Php under the_hood
Php under the_hood
What do you think of copy &
paste code?
Php under the_hood
What do you think of traits?
Php under the_hood
Cool. Traits are for...
● Code reusage
● Multiple inheritance
● Keeping stuff you often use in different
contexts
● No need for complex OOP architectures
Nooooooo!
Seriously...
No.
No. Because traits are...
● Copied into every single class at compile-
time
● Therefore not runtime bindable
● Not testable
● Tightly coupled
● Make it easier to cross SRP (one god-class)
(traits === copy & paste)
Wanna read more?
● PHP at the Core: A Hacker's Guide
● PHP Compiler Internals
● PHP OpCodes
● PHP Internals
● Are Traits The New Eval?
● PHP-RFC’s
So you’re telling me not to use
such cool features in PHP?
No.
Just be aware of how
things work in PHP
while writing code
Php under the_hood
Frank Neff
Software Engineer
Thanks
http://stickerish.com/
http://xhprof.io/
http://www.vbulletin.com/
http://en.wikipedia.org/
http://blog.supermedia.com/
http://twitter.com/
http://tossfair.wordpress.com/
http://juliannb4.deviantart.com/
http://www.walldime.com/
http://gist.github.com
http://meanduchicago.wordpress.com/
Images ● @frank_neff
● github.com/frne
● speakerdeck.com/frne
● frankneff.ch
● ymc.ch

More Related Content

What's hot (20)

PPTX
Php 7 - YNS
Alex Amistad
 
PPTX
Php 5.6 vs Php 7 performance comparison
Tu Pham
 
PPTX
Php
Gangadhar S
 
PPTX
A brief to PHP 7.3
Xinchen Hui
 
ODP
30 Minutes To CPAN
daoswald
 
PPTX
Switch case and looping new
aprilyyy
 
PPTX
PSR-7 - Middleware - Zend Expressive
Milad Arabi
 
PDF
10 reasons to be excited about go
Dvir Volk
 
PDF
PHP 7X New Features
Thanh Tai
 
PPT
Php hypertext pre-processor
Siddique Ibrahim
 
PDF
The Parenscript Common Lisp to JavaScript compiler
Vladimir Sedach
 
PPTX
My final requirement
katrinaguevarra29
 
PPTX
Yeahhhh the final requirement!!!
olracoatalub
 
PDF
Phpbasics
PrinceGuru MS
 
PPTX
introduction to server-side scripting
Amirul Shafeeq
 
PPT
01 Php Introduction
Geshan Manandhar
 
PPTX
Macasu, gerrell c.
gerrell
 
PPT
PHP - Introduction to PHP Fundamentals
Vibrant Technologies & Computers
 
PDF
Dynamic PHP web-application analysis
ax330d
 
Php 7 - YNS
Alex Amistad
 
Php 5.6 vs Php 7 performance comparison
Tu Pham
 
A brief to PHP 7.3
Xinchen Hui
 
30 Minutes To CPAN
daoswald
 
Switch case and looping new
aprilyyy
 
PSR-7 - Middleware - Zend Expressive
Milad Arabi
 
10 reasons to be excited about go
Dvir Volk
 
PHP 7X New Features
Thanh Tai
 
Php hypertext pre-processor
Siddique Ibrahim
 
The Parenscript Common Lisp to JavaScript compiler
Vladimir Sedach
 
My final requirement
katrinaguevarra29
 
Yeahhhh the final requirement!!!
olracoatalub
 
Phpbasics
PrinceGuru MS
 
introduction to server-side scripting
Amirul Shafeeq
 
01 Php Introduction
Geshan Manandhar
 
Macasu, gerrell c.
gerrell
 
PHP - Introduction to PHP Fundamentals
Vibrant Technologies & Computers
 
Dynamic PHP web-application analysis
ax330d
 

Similar to Php under the_hood (20)

PPTX
Xdebug
Bryce Embry
 
PDF
PHP QA Tools
rjsmelo
 
PDF
Building and Deploying PHP Apps Using phing
Mihail Irintchev
 
PPTX
PHP Profiling/performance
Nicolas Degardin
 
PDF
Getting Started with PHP Extensions
MichaelBrunoLochemem
 
ODP
Tool it Up! - Session #1 - Xhprof
toolitup
 
PDF
Profiling PHP - AmsterdamPHP Meetup - 2014-11-20
Dennis de Greef
 
PPT
Php Code Profiling Using X Debug
SergeyChernyshev
 
PDF
Profiling PHP - PHPAmersfoort Meetup 2015-03-10
Dennis de Greef
 
PPT
Hacking with hhvm
Elizabeth Smith
 
PPTX
Listen afup 2010
Gabriele Santini
 
PPT
PHP: Debugger, Profiler and more
Võ Duy Tuấn
 
PPTX
Listen and look at your PHP code
Gabriele Santini
 
PPTX
Performance Tuning with XHProf
Salesforce Engineering
 
PPTX
PHP Fundamentals: A Comprehensive Introduction
Nilesh Valva
 
PDF
PHP Jump Start
Haim Michael
 
ODP
Wc13
Pomaxa None
 
PDF
Php tutorial2
Marko Ancev
 
PDF
Manual oficial de php5
Oscar Sibaja
 
PDF
PHP Internals and Virtual Machine
julien pauli
 
Xdebug
Bryce Embry
 
PHP QA Tools
rjsmelo
 
Building and Deploying PHP Apps Using phing
Mihail Irintchev
 
PHP Profiling/performance
Nicolas Degardin
 
Getting Started with PHP Extensions
MichaelBrunoLochemem
 
Tool it Up! - Session #1 - Xhprof
toolitup
 
Profiling PHP - AmsterdamPHP Meetup - 2014-11-20
Dennis de Greef
 
Php Code Profiling Using X Debug
SergeyChernyshev
 
Profiling PHP - PHPAmersfoort Meetup 2015-03-10
Dennis de Greef
 
Hacking with hhvm
Elizabeth Smith
 
Listen afup 2010
Gabriele Santini
 
PHP: Debugger, Profiler and more
Võ Duy Tuấn
 
Listen and look at your PHP code
Gabriele Santini
 
Performance Tuning with XHProf
Salesforce Engineering
 
PHP Fundamentals: A Comprehensive Introduction
Nilesh Valva
 
PHP Jump Start
Haim Michael
 
Php tutorial2
Marko Ancev
 
Manual oficial de php5
Oscar Sibaja
 
PHP Internals and Virtual Machine
julien pauli
 
Ad

Recently uploaded (20)

PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
July Patch Tuesday
Ivanti
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
July Patch Tuesday
Ivanti
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Biography of Daniel Podor.pdf
Daniel Podor
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Ad

Php under the_hood