Using Zendencode to compile PHP programs

Source: Internet
Author: User
Tags execution install php php compiler php script zend

First, the working principle of Zendencode

People who use PHP know that it is a scripting tool, written by the program, must be in the form of the source code to be placed on the Web server, so we can not protect their own sources. And as you all know, the efficiency of any script execution is slow compared to the compiled binary code with the same functionality. Then if there is a tool to help us write the program in PHP into binary code, so that not only to improve the efficiency of implementation, and speed up the operation. If there was such a tool, it would be a two win.

Right, just released the Zendencode is to develop for this. Zendencode can directly compile the script into binary code. With Zendencode, you can write your own PHP program, compiled and distributed to many users, rather than exposing their source code. Compiled binaries can be read transparently by Zend Optimizer, that is, a client can perform a PHP program compiled by Zendencode by installing Zend Optimizer on his server as well. The compiler contains part of the code for Zend Optimizer, so the program code is optimized further during compilation, which means that the execution efficiency of the script is improved.

In some sense, Zendencode is a "PHP compiler". However, it is not a real compiler, the real compiler will be separated from the original compilation environment, and Zendencode compiled programs, but also have zendoptimizer support, just like the compiled Java binary code, it must have a JVM to run. So, Zendoptimizer can also be seen as PHP compiled code of the virtual machine. Anyway, it's one of those things that they have to do with each other.

The operating systems currently supported by Zendencode are: Solaris,linux,freebsd and Windows. Zendencode can be run directly, your system does not have to install PHP.

Second, the installation of Zendencode (in the case of Linux installation for example)

Download a package first! Zendencode is not free software, it pays to use it, and the price is quite high. Luckily Zend.com offers a software package that can be tested for a free trial for 30 days. This package can be obtained directly from the http://www.zend.com/. So, first of all, go to http://www.zend.com/download Zendencode, Zendoptimizer package. Second, to download an authorization file, that is, license. Since Zendencode is a licensed product, users are required to apply for a license from zend.com. Application card steps are as follows:

To apply for a trial license, you need to provide zend.com with the ID of the computer you are using, the host ID (which is actually the MAC address of the NIC on your computer) that you want to fill out on the application page. To view the computer ID is as follows: Download a lmutil.z program from zend.com, extract the program Lmutil, run it, will produce a sequence according to the hardware characteristics of the system. Fill in the HostID of the Application License page, zend.com will generate a license for the user within 48 hours, download this license file, the file name is ZendEncode.dat, it is the only one that can be used on your computer.

1, the Zendencode software package is also extracted in the/usr/local/zend directory. After the decompression is complete, the directory has a Zendenc file, it is the "compiler".

2, copy the license file to the/usr/local/zend directory

Installation complete.

Third, the installation of Zendoptimizer

Completed the installation of Zendencode, only half of the task, to use the compiled PHP binary code, but also to install an interpreter-zendoptimizer, with its support, the compiled PHP binaries can be correctly executed.

Unlike Zendencode, Zendoptimizer is a free software, its main function is to speed up the operation of PHP script files, according to Zend.com said, with Zendoptimizer optimization, program execution efficiency can be increased by 600%, after the author's simple test , the efficiency of implementation has indeed improved a lot.

Install Zendoptimizer steps as follows:

1, unzip the Zendoptimizer software package, copy the zendoptimizer.so file to the/usr/local/zend/lib directory

2, open the/usr/local/lib/php.ini file, add the following two lines in the file:

Zend_optimizer.optimization_level=15

zend_extension= "/usr/local/zend/lib/zendoptimizer.so"

3, restart the Apache server, make the above update effective

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.