Home php Compiling php

Compiling php

Author

Date

Category

The question is whether php can be compiled to run on the server (i.e. not interpreted through the php engine, but compiled and called)?

The fact is that I found an article on Habré comparing twig with smarty and there was a plate with a compilation graph. So I didn’t understand how they compiled and whether they meant compiling a php script or template into a quick php script (as smarty does).

I was also interested in the possibility of compiling to sell turnkey sites.


Answer 1, authority 100%

There is also such a thing, as Wikipedia says

Zend Guard (formerly Zend
Encoder) – allows you to encode
script into bytecode, which you can then
use just like
normal except for the possibility
edit it. Designed for
protection of interests and intellectual
developer property. For work
such scripts are required by Zend
Optimizer.

Zend SafeGuard Suite is the same as
as Zend Encoder, only augmented
Zend License Manager which
allows you to create licenses for
encoded scripts. You can ask
time (expire) and conditions (binding to
IP, MAC, etc) works. Convenient for
Shareware versions or demos.

Zend Optimizer is the only one
application distributed
is free. Is a server
module to run encoded with
using Zend Encoder and Zend SafeGuard
Suite of scripts, as well as a few of them
accelerating (declared to be up to 40%).

For more details on Zend developments, find here . The prices, however, are prohibitive, but I would consider as an option.


Answer 2, authority 100%

Facebook compiles PHP to C++ using HipHop . It seems like this is the fastest solution available at this time. However, some constructs are not supported, for example, eval () .

Compared to PHP + Apache (mod_php), according to Facebook, it saves about 50% of CPU time when uploading a web interface, and about 30% when uploading an API.

There was also (now, one might say, died of lack of interest ) Raven project from Roadsend, which compiled into LLVM bytecode, with all the ensuing advantages of it (portability between platforms / architectures, JIT, etc. .)


Answer 3, authority 100%

For example – http://www.phpcompiler.org/

from page

phc for PHP programmers (See Manual):

  • Compile PHP source into an (optimized) executable (supports entire PHP standard library).
  • Compile a web application into an (optimized) extension (supports entire PHP standard library).
  • Pretty-print PHP code.
  • Obfuscate PHP code (–obfuscate flag – experimental).
  • Combine many php scripts into a single file (–include flag – experimental).
  • Optimize PHP code using classical compiler optimizations (in the dataflow branch – very experimental).

    • compiling php into an (optimized) executable (with full support for standard php libraries)
    • compiling a web application into a (optimized) extension (with full support for standard php libraries)
    • obfuscating PHP code (changing the code to make it difficult to parse and understand) (experimental)
    • combining several php scripts into one file
    • optimization of php scripts using classical optimization methods (experimental version)

Answer 4

Compilation is not about php – It’s an interpreted language.
Its code is interpreted on the server.

twig with smarty Compared maybe they are really needed in compilation (and their processing speed is different).

And php, by the way, is also a template engine, and a native one. smfrty and with them are designed to deepen (aggravate) the principle of MVC, so that when displaying html code there is no temptation to modify the data

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions