What is bcompiler ?

What is Bcompiler?

Bcompiler is a PECL extension used for compiling php scripts to opcode or bytecode. It is a useful way to convert PHP to bytecode, which can then be converted to binaries. Bcompiler stands for bytecode compiler which enables to encode your scripts in php bytecode, enabling you to protect the source code. Bcompiler is used to create EXE type files and it has to be used with a modified file or a version of PHP which has been compiled as a shared library. In this case, bcompiler reads the compressed bytecode from the end of the exe file. Bcompiler can be used to improve the performance when used with uncompressed bytecodes only. In the case of uncompressed bytecode, it can be up to 5 times larger than the original source code. Bytecode compression allows you to save your space, but decompression requires much more time than parsing a source. Bcompiler does not do any bytecode optimization.  In terms of code protection, bcompiler is safe because it would be impossible to recreate the exact source code that it was built from, and without the accompanying source code comments. It is possible to retrieve data from a bcompiled bytecode file so do not enter your private passwords or anything in it.


Bcompiler as an Encryption Solution

Bcompiler was developed to provide a bytecode compiler transport. It will allow PHP to be used in a larger arena (breaking into desktop applications), for improved performance by eliminating run-time compiles. It provides a solution to the growing concerns with code obfuscation. Products like Zend and IonCube offer encryption atop the bytecode transport, the use of compiled code makes the task of reverse-engineering software extremely challenging.


Functions of bcompiler

1) bcompiler_load_exe: It is used to read and create classes from a bcompiler exe file.

2) bcompiler_load: It reads data from a bzcompressed file and creates classes from the bytecodes.

3) bcompiler_parse_class: Reads the bytecodes of a class and calls back to a user function.

4) bcompiler_read: Reads and creates classes from a file handle

5) bcompiler_write_class: Writes a defined class as bytecodes

6) bcompiler_write_constant: Writes a defined constant as bytecodes

7) bcompiler_write_exe_footer: Writes the start pos, and sig to the end of a exe type file

8) bcompiler_write_file: It writes a php source file as bytecodes.

9) bcompiler_write_footer: Writes the single character \x00 to indicate End of compiled data.

10) bcompiler_write_function: Writes a defined function as bytecodes

11) bcompiler_write_functions_from_file: It Writes all functions defined in a file as bytecodes.

12) bcompiler_write_header: It writes the bcompiler header.

13) bcompiler_write_included_filename: Writes an included file as bytecodes.


Uses of bcompiler

1) To create an exe file of a PHP-GTK application (in conjunction with other software)

2) To create closed source libraries

3) Provide clients with time expired software (prior to payment)

4) Deliver close source applications

5) Embedded systems, where disk space is a priority.



1) To encode entire script in a proprietary PHP application.

2) To encode some classes and/or functions in a proprietary PHP application.

3) To enable the production of php-gtk applications that could be used on client desktops.

4) To do the feasibility study for a PHP to C converter.



1) Download the file.

# wget http://pecl.php.net/get/bcompiler-1.0.2.tgz

2) Extract file

    # tar -xvf bcompiler-1.0.2.tgz

3) Run the following commands

   # phpize

# ./configure

# make

# make install

# make test

4) Edit php.ini file

   # vi /etc/php.ini

uncomment the line “extension=bcompiler.so”

5) Restart apache

   # service httpd restart


If you need any further assistance please contact our support department.