Making PHP executables
IntroductionI am writing this to show out different ways we can achieve to create an executable in php,the benefits of these will vary according to what you intend to achieve.
1. Basically you may want to create a service in php that can be invoked as a windows executable
2. You may need to compile your php program to byte code this means the compiled source code not easily viewable.
3. You may have as more reasons to do this.
My analysis falls into the three which are used widely as follows :
1. Using Bambalam Php Exec Compiler/Embedder
- Download the application from : http://www.bambalam.se/bamcompile/
- Unzip it to preferred folder in this case I use folder in directory :
- Open command line interface and Cd to that directory
- I will use a command : bamcompile [-options] infile.php [outfile.exe] – to genereate my exe
- I create my php file as shown :
- Then i will save it as project1.php.
- To make it executable, i will now type as shown : bamcompile project1.php project1.exe
- On the folder i will now find my executable :
When i run it shows output in the commandline
RecommendationThis application is good for projects that do not require ot have an interface e.g php service that runs in the background
2. Use of Phalanger 126.96.36.19972
- Download the application from http://phalanger.codeplex.com/
- Run setup to install the application (requires .net framework 4.0 and above)
- Install Phalanger Tools for Visual Studio (Ensure you have visual studio 10 and php version 5.4 and above)
- Go to file and create new Project as shown:
- In the directory structure you will have necessary files generated as shown:
- Once you run the project ,the executable is found as :
as an exe .
3. Using ZZEE PHP ExeDownload the application from : http://www.zzee.com/phpexe/
After installing,set the source folder of your php files as shown:
- The second option after Main,(Exe File), allows you put details of executable you want to create as shown:
- On the Application ZZEE Php Exe, you will need to edit the option Php.ini and uncomment ‘extension=php_mysql.dll’ so as to allow connections to the database as shown:
- Declare the output of your executables on the second option,for this case i use output C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\Compile Php Executables\ZZEE PhpExec\CompiledProjects\VendorsExecutable
- To generate my sample vendor program
- In the output directory you will find the executable file