java2db

How to create PHP RESTful web service and client with example



RESTful web services are made to work best for Web based applications. To create PHP RESTful web service and client, we no need to add any additional php libraries .

create PHP RESTful web service and client Int the below example we used XAMPP server to run the application .

 click here to download XAMPP web server 

Steps to create PHP RESTful web service (Service provider):

Step 1 :

Create PHP files in the server specified location (If you are using XAMPP server , create in htdocs folder). The directory structure as follows .

 

create PHP RESTful web service and client

 

 Step 2 :

Copy the below code in appropriate php file.

functions.php

RESTfulPHPService.php

 

 Step 3 :

Run the PHP web server ( XAMPP or WAMP ) .

 

 Step 4 :

Open the browser and enter the URL to test the application .

URL : http://localhost/phpServiceExe/RESTfulPHPService.php?wonderName=Colosseum 

http://  represents the protocol .

localhost is the local machine ip (127.0.0.1).

phpServiceExe  is the directory that we created in server location.

RESTfulPHPService.php is the php file name that we need to test.

wonderName  is the parameter name .

Colosseum  is the value.

 

The output as follows .

create PHP RESTful web service and client

 

Now , we tested the PHP  Service from the web browser. In the same way, we can test it from the PHP RESTful web service client like below.

 

 

 

Steps to create PHP RESTful web service client (Service Consumer) :

 

 Step 1 :

Create a PHP file in the same or different directory in the server location and copy the below code .
RESTfulPHPClient.php

 

 Step 2 :

Open the web browser and enter the URL to access/call the PHP web service from client program .

URL : http://localhost/phpServiceExe/RESTfulPHPClient.php 

http://  represents the protocol .

localhost is the local machine ip (127.0.0.1).

phpServiceExe  is the directory that we created in server location.

RESTfulPHPClient.php  is the client PHP program to consume PHP RESTful web service.

 

The output as follows .

create PHP RESTful web service and client




Related Posts :
How to call C# .Net WCF web service in PHP SOAP client
How to call PHP RESTful web service in java client
How to call java RESTful web service in PHP client
How to create a java client to call PHP SOAP web service
How to call java SOAP web service in php ( php web service client )
   [will not be published]



^ <