You are here
Home > Php > How to Create Web Service in PHP

How to Create Web Service in PHP

Hello Friends, Today I am going to tell you about how to create web service in PHP. A web service is a software or program which makes itself available over Internet to give response according to inputs provided to web service. In a Web service, HTTP protocol is used for communication and response is generated to client in XML or JSON format. Web Services can be utilized by web application, mobile applications or desktop applications. Web Services can be created using Java, .Net, PHP or any other languages but I am going to use PHP and response will be generated in JSON format. I am going to create a web service for user registration and login.

Folder Structure


Note: website root folder can be public_html or a subfolder or depend on your web server and how to setup your website



Service url will be SITE_URL/api/user.php

How to Access Web Service

Registration Web Service

SITE_URL/api/user.php?key=ABCD&action=register&name=Test&mobile=9999999999&[email protected]&password=test
i.e.[email protected]&password=test

Login Web Service


Note: Here I am using GET method you can also use POST method


Please share if you like and you can ask in comment section if you have any query

Rajesh Kumar Sahanee
I am a passionate Java Developer and I like Computer Programming. I love to do some interesting experiments and listening music in my free time.