Link to home
Start Free TrialLog in
Avatar of mwskuzzy
mwskuzzy

asked on

How to create a PHP Web Service in Windows

Hi All

I have ordered the book PHP Programming for Windows with some nice material on how to create a PHP webserice on Windows. The problem it will only be here in two weeks and I really need to do it now. Is there any good material on how to do this online. Please help.

mwskuzzy
Avatar of Richard Quadling
Richard Quadling
Flag of United Kingdom of Great Britain and Northern Ireland image

Ideally, for a web service, you need a web server. Then PHP plugs into that (ISAPI/FCGI/CGI/etc).
ASKER CERTIFIED SOLUTION
Avatar of Stacy Spear
Stacy Spear
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mwskuzzy
mwskuzzy

ASKER


I need to develop a web service in PHP for Windows. I have already learnt how to program in PHP on a web server. I am just looking for some good documentation or source code examples of how to create a PHP web service for Windows.
PHP is PHP. Whether windows or *AMP.

The folks on the other end of the service won't know or care what platform you are running on.
Use the server (where php acts as a service) code examples in your book and run the php script using the php.exe to run the script outside the webserver. Create a new service in windows using the "sc create" command on the command prompt and point it to the executable with the correct instructions. Do mind using appropriate service accounts rather then the default SYSTEM account services are ran under.

Grant this user "run as service account / batchjob" privs...

Start the service in windows, or use the scedurer if the script isnt in a loop for instance...

Regards,
A nice example of a windows service in php is this one for example..

<?php
/* A sample service:
 *
 * php sample.php install
 * net start dummyphp
 * net stop dummyphp
 * php sample.php uninstall
 */

if ($argv[1] == 'install') {
      $x = win32_create_service(array(
            'service' => 'dummyphp',
            'display' => 'sample dummy PHP service',
            'params' => __FILE__ . ' run',
      ));
      debug_zval_dump($x);
      exit;
} else if ($argv[1] == 'uninstall') {
      $x = win32_delete_service('dummyphp');
      debug_zval_dump($x);
      exit;
} else if ($argv[1] != 'run') {
      die("bogus args");
}

$x = win32_start_service_ctrl_dispatcher('dummyphp');

while (WIN32_SERVICE_CONTROL_STOP != win32_get_last_control_message()) {
      usleep(250000);
}

?>
Guys....

He he.....thank you all for your suggestions but I require help to create a WEB SERVICE (as in SOAP, XML) not a windows service.
In a nutshell I need to do the following:

1. Create a PHP web service with the required methods.
2. Create a WSDL file from the web service
3. Import the WSDL file into Delphi
4. Call the methods
Did you even read the link I posted? Which walks you through the creation of a web service?
Hi darkstart3d

I read through the link you posted and it does help yes but not in the detail required. It seems as though to create a web service in PHP you need to manually create your WSDL file for your web service. The details on how to do this arent very thorough but w3schools.com com has a fairly decent turorial on WSDL files. There are a few applications to create these files through a GUI but the cost dosent justify it as I only need one file. The great thing is that i get a chance to get my hands dirty and learn the nitty gritty of how a WSDL file works.

Regards