Your SlideShare is downloading. ×
0
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 tryi...
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 ...
Looks like this
Try it with your code
http://xhprof.io/
Compiling at runtime is slow!
OpCode Cache
● Performance enhancing extension for PHP
● Hooking into the execution life-cycle
● Caching the results of th...
HHVM
● HipHop Virtual Machine
● Designed for executing PHP programs
● Predecessor HPHPc makes C out of PHP
● Uses a just-i...
LetsTalkAboutNamespaces
Kidding me?
No!
● Namespaces in PHP are just class-prefixes
● They are added to each classname by the
compiler
● The result is called ...
What do you think of copy &
paste code?
What do you think of traits?
Cool. Traits are for...
● Code reusage
● Multiple inheritance
● Keeping stuff you often use in different
contexts
● No nee...
Nooooooo!
Seriously...
No.
No. Because traits are...
● Copied into every single class at compile-
time
● Therefore not runtime bindable
● Not testabl...
(traits === copy & paste)
Wanna read more?
● PHP at the Core: A Hacker's Guide
● PHP Compiler Internals
● PHP OpCodes
● PHP Internals
● Are Traits T...
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
Frank Neff
Software Engineer
Thanks
http://stickerish.com/
http://xhprof.io/
http://www.vbulletin.com/
http://en.wikipedia...
Php under the_hood
Php under the_hood
Php under the_hood
Php under the_hood
Php under the_hood
Php under the_hood
Php under the_hood
Php under the_hood
Php under the_hood
Upcoming SlideShare
Loading in...5
×

Php under the_hood

124

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
124
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
6
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Php under the_hood"

  1. 1. PHP under the hood Frank Neff
  2. 2. PHP
  3. 3. is
  4. 4. compiled
  5. 5. at
  6. 6. runtime!
  7. 7. Source code you write...
  8. 8. …OpCodes you run
  9. 9. Kidding me?
  10. 10. Looks confusing, but this is... ● how PHP works ● cool for debugging purposes ● visualizing code complexity ● helpful trying to understand opcaches like APC
  11. 11. Try it with your code http://explain.php.net.so
  12. 12. So this is about profiling?
  13. 13. 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
  14. 14. Looks like this
  15. 15. Try it with your code http://xhprof.io/
  16. 16. Compiling at runtime is slow!
  17. 17. 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
  18. 18. 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/
  19. 19. LetsTalkAboutNamespaces
  20. 20. Kidding me?
  21. 21. 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
  22. 22. What do you think of copy & paste code?
  23. 23. What do you think of traits?
  24. 24. Cool. Traits are for... ● Code reusage ● Multiple inheritance ● Keeping stuff you often use in different contexts ● No need for complex OOP architectures
  25. 25. Nooooooo!
  26. 26. Seriously...
  27. 27. No.
  28. 28. 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)
  29. 29. (traits === copy & paste)
  30. 30. 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
  31. 31. So you’re telling me not to use such cool features in PHP?
  32. 32. No. Just be aware of how things work in PHP while writing code
  33. 33. 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
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×