Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why compile a PHP File?

Tags:

php

build

hiphop

A friend of mine told me recently "to optimize your site you may want compile your php files" and i was like "what?"

I honestly i never heard of that, i'm a "advanced-naive" programmer, that means i'm self taught, i built complex sites but i'm still missing something...

Bottom line:

what does it mean compile php? convert them in exe files? why? is faster?

like image 412
Francesco Avatar asked May 05 '11 15:05

Francesco


2 Answers

While PHP code needs to be interpreted on every call, bytecode is precompiled code that runs almost instantly. Mostly you will only really need it, if you are running a larger website.

The following tools can be used to compile scripts or run compiled scripts:

  • eAccelerator
  • Zend Optimizer
  • PHC (http://www.phpcompiler.org/)
  • Alternative PHP Cache (APC)
like image 93
JimmyBlu Avatar answered Oct 06 '22 00:10

JimmyBlu


Unless you're after serious performance then compiling PHP using something like Facebook's HipHop is probably a bit excessive.

I'd just install/configure Alternative PHP Cache (APC) on your machine which will cache the compiled bytecode and should give you an instant performance boost.

like image 30
James C Avatar answered Oct 06 '22 00:10

James C