Monday 21 July 2014

PHP web applications as executables

Making PHP executables
Introduction
I 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
C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\Compile Php Executables\BMCompile
  • 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
        If successfull shows in the commandline as picture below:
          • On the folder i will now find my executable :
            When i run it shows output in the commandline
            Recommendation
            This 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 3.0.0.4072
            • 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 :
                  C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\Compile Php Executables\PhpLanger\Projects\winApp\winApp\bin\Debug

                  as an exe .

                  3.    Using ZZEE PHP Exe
                  Download 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
                            • Click on button in green to compile the code (php and javascript) to the output directory
                            • In the output directory you will find the executable file
                              Recommendation:
                              Can be used to compile files containing flash,javascript,embedded php code.

                              No comments:

                              Post a Comment