Your SlideShare is downloading. ×
Php under the_hood
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Php under the_hood

88
views

Published on

Published in: Technology

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

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

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

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