Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PHP under the hood

Frank Neff
December 19, 2013

PHP under the hood

A talk with some examples how PHP works internally. There are also some examples how namespaces and traits are compiled and how to profile a PHP app.

Please download pdf to open the links...

Frank Neff

December 19, 2013
Tweet

More Decks by Frank Neff

Other Decks in Programming

Transcript

  1. PHP

  2. is

  3. at

  4. Looks confusing, but this is... • how PHP works •

    cool for debugging purposes • visualizing code complexity • helpful trying to understand opcaches like APC
  5. 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
  6. 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
  7. 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/
  8. 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
  9. Cool. Traits are for... • Code reusage • Multiple inheritance

    • Keeping stuff you often use in different contexts • No need for complex OOP architectures
  10. No.

  11. 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)
  12. 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
  13. 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