Monday, 21 July 2014

PHP web applications as executables

Making PHP executables
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
            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
            • Download the application from
            • 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 :
                  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
                              Can be used to compile files containing flash,javascript,embedded php code.

                              Wednesday, 16 July 2014

                              Starting with ZF2 Developer Crash Guide

                              I have come up with this guide to help software developers set up an environment and working zend framework.I am going to be very brief and straight forward on this and will have an assumption of prior programming knowledge on my entire reader of this.

                              Initial Installation

                              1. Install the following components:
                              Ø  Install composer
                              Ø  Intall tortoise svn

                              For composer you will be required to locate path to your php.exe which should be version 5.5 and above.

                              1. Install ZF2 skeleton application from :

                              1. Open your command prompt ,if composer is rightfully installed, > composer –version will give you some output.
                              To create a skeleton app:
                              Type this line on your command prompt:

                                >composer create-project -sdev --repository-url="" zendframework/skeleton-application C:\Framework\ZK

                              1. Going to your root directory you will find the downloaded files,check the root :
                              For a folder structure of the ZF2 application that you are going to start on

                              1. Edit some configuration on the server to add the vhost
                              Start with the httpd.conf  this is located on your computer under the directory :
                              and uncomment this line below :
                              # Virtual hosts
                              Include conf/extra/httpd-vhosts.conf

                              This allows you to define some virtual host in the web server
                              Open file httpd-vhosts located on your computer under the directory :
                              and add your virtual hosts(remember to put the default for the rest of your sites)
                              See below:
                              <VirtualHost *:80>
                                  ServerName localhost
                                  DocumentRoot "C:\Apache24\htdocs" 
                              <VirtualHost *:80>
                                  ServerName fileserver
                                  DocumentRoot "C:\Apache24\htdocs" 
                              <VirtualHost *:80>
                                  DocumentRoot "C:\Apache24\htdocs" 

                              <VirtualHost *:80>
                                  ServerName zf2-tradestar
                                  DocumentRoot "C:\Apache24\htdocs\Code\Framework\ZK\public"
                                  SetEnv APPLICATION_ENV "development"
                                  <Directory "C:\Apache24\htdocs\Code\Framework\ZK\public">
                                      DirectoryIndex index.php
                                      AllowOverride All
                                      Order allow,deny
                                      Allow from all

                              1. Add your virtual host to your computer under the file : C:\Windows\System32\drivers\etc
                              So that you can meake a resolution to the virtual hosts that you have added.
                              The file is named as hosts

                              1. When you have done all this access your web page and you should be having this :

                              1. Install doctrine in your folder and other libraries

                              So far so good am hoping so, much has been done here and the rest you will only need to load the additional libraries to you composer.json located under :

                              Cd to this directory.
                              1. Now creating the additional dependencies , doctrine and php-unit,open the composer.json and add the following lines :

                              Then go to your command prompt and type:
                              >composer update

                              Wait for it to download and update the dependencies.
                              After Finnish you will need to add a few lines so as to make use of the Doctrine ORM,Add the following lines 

                              alter file config/application.config.php and Add lines

                              'modules' => array(

                              Enjoy coding in ZF2 Framework!!

                              Undo Virus Hidden File Activity Without flash Disk Formatting

                              At times you may have inserted your flash disk into a virus manifested computer and realize that all your files and folders become shortcuts, further to this the shortcut locate to your original files that have now been set hidden to your flash.

                              Looking at the properties, you may find that the size in your flash disk is all the same.

                              I am now going to show you how to revert all this through command prompt.

                              Click on start button and click Run. 

                              1.      Type Cmd on the run dialog box and press Enter. A command prompt appears where we have to type the commands. Double click on the title bar to maximize the command prompt or else press Alt+D+Enter to work with a full screen.

                              2.      On the command line, type the drive letter that you need to recover the files from e.g. H: and press enter. The entry point of your command should now read the drive letter.

                              3.      Type "dir /a:h" (without the quotes) and press Enter. Dir is the short for directory while "/a:h" is a switch used to display only the hidden files. Otherwise, /a only will enable the display of all the files and directories in the drive including the unhidden ones. If no hidden files are in the drive, typing /a:h will indicate directory not found.

                              4.      Having seen the hidden items, we need now to make them be displayed in windows by removing the hidden properties. Now type, attrib -h -s -r *.* (notice the spaces) and press Enter. Attrib is the short for attribute while -h is to remove any hidden property on the files, -s to deactivate any properties set as system files while -r removes the read-only properties. *.* represents a string of characters for the names of the items in the drive. Most viruses will come with the above properties turned on so that you can't delete them easily.

                              5.      Incase of a suspicious file and you may need to delete it, type del (file name together with the extension) and press Enter. e.g. del xyzg.inf

                              6.      Type Exit and press Enter to escape the cmd window. When you try to access your drive now from My Computer, you will notice that the items have been restored and thats it buddie!!! you have your data back.

                              NB : my as parameter will allow for the folder to be unset as hidden