Php under the_hood
Upcoming SlideShare
Loading in...5
×
 

Php under the_hood

on

  • 104 views

 

Statistics

Views

Total Views
104
Views on SlideShare
104
Embed Views
0

Actions

Likes
1
Downloads
1
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Php under the_hood Php under the_hood Presentation Transcript

  • 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/
  • 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/
  • LetsTalkAboutNamespaces
  • 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
  • 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 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
  • 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