wodWebServer ActiveX Control - Running PHP as ISAPI extension
® WeOnlyDo! COM (2002-2004)
 

General information

This tutorial will show step by step how to setup PHP to work with wodWebServer, running as loaded ISAPI extension. It assumes you have installed wodWebServer to your local folder, and tested it so it works with provided samples.

Step 1 - installing PHP

You should download PHP installation from http://www.php.net, and install it into C:\PHP folder.  PHP.EXE should exist in that folder.
Also, PHP.INI must exists there. You can use unmodified PHP.INI-dist file that comes with PHP distribution, just rename to PHP.INI. To make sure it works, you can run "PHP -i" from C:\PHP folder, which should result in HTML content to be returned to your command prompt window.

Copy PHP4TS.DLL (PHP5TS.DLL in PHP5) file from C:\PHP to C:\WINDOWS\SYSTEM32 for PHP to operate correctly!

If you get an error 'ISAPI Extension file could not be loaded' and you are 100% sure you followed above steps, then most probably this is directory/path issue. For start, try to move your code to C:\PHP folder and execute it from there (just for a test).

 

Step 2 - using PHP from VB (similar approach is needed for any other language)

Fire up new VB project, and add wodWebServer to it. Start it so it listens and accepts incoming connections. Typically, code will look like this

Option Explicit
Dim WithEvents Http1 As wodWebServerCom

Private Sub Form_Load()
   Set Http1 = New wodWebServerCom

   On Error Resume Next
   Http1.Start
   If Err Then
      MsgBox "There was an error: " & Err.Description, vbOKOnly, "Error"
   End If
End Sub

Now server will accept connections, but will not know what to do with PHP requests. So, we need to load appropriate PHP ISAPI extension, like this:

Private Sub Form_Load()
   Set Http1 = New wodWebServerCom


   Http1.DocumentRoot = App.Path
   Http1.ISAPI.Add "c:\php\sapi\php4isapi.dll"
' use php5isapi.dll for PHP5

  
On Error Resume Next
   Http1.Start

   ......

It is important to set DocumentRoot property because many ISAPI extensions will need proper mapping information - how to resolve requested URI to a file on disk.

When PHP request arrives from the client, we need to process it. The most convenient place to so that is RequestDone event, so you can do this:

Private Sub Http1_RequestDone(ByVal User As WODWEBSERVERCOMLib.IWebUser)
        User.Response.ISAPIExecute 0, User.Request.URI, User.ResolveURI(User.Request.URI)
End Sub

Above code is self-explanatory. It calls our ISAPI with two arguments: requested path, and resolved path of the script.

Conslusion

That should be it! If you point your browser to local instance of wodWebServer, you will see PHP running there.