PHP Classes

How to Create a PHP REST API Learning from a PHP API Package PHP Basic API: Process HTTP requests as a REST API

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2025-01-20 (4 days ago) RSS 2.0 feedNot yet rated by the usersTotal: Not yet counted Not yet ranked
Version License PHP version Categories
php_basic_api 1.0.0BSD License5PHP 5, Web services
Description 

Author

This package can process HTTP requests as a REST API.

It provides a base class that API developers can extend to implement a REST API that receives HTTP requests from API clients and returns responses.

The package also provides an API class that extends the base class to implement an actual API.

Picture of Kabir Hossain
  Performance   Level  
Name: Kabir Hossain <contact>
Classes: 4 packages by
Country: Bangladesh Bangladesh

Documentation

Simple RESTful API implementation in PHP

A very simple implementation of RESTful API in PHP for managing Orders and Users pertaining to an Online Food Catering Service. Error and exception handling are at their minimum.

Functionality provided by the REST API:

User related: * fetch details for a particular user * create a new user. * update user details. * delete an existing user

MySQL tables : * users

    
    CREATE TABLE `users` (
    `user_id` int(11) NOT NULL AUTO_INCREMENT,
    `user_fullname` varchar(25) NOT NULL,
    `user_email` varchar(50) NOT NULL,
    `user_password` varchar(50) NOT NULL,
    PRIMARY KEY (`user_id`)
    );
          

API Functions :

An API function can be invoked by passing the function name in url as parameter 'q' e.g. http://localhost/api.php?q=functionName

  • insertUser() - Insert a new user in users table

    Method : POST Required Parameters - 'name' : User Name 'email' : User Email ID 'pwd' : Password

  • updateUser() - Update details of a user

    Method : PUT Required Parameters - 'id' : ID of the user to be updated 'name' : User Name 'email' : User Email ID 'pwd' : Password

  • deleteUser() - Delete user with specific ID

    Method : DELETE Required Parameters - 'id' : ID of the user to be deleted

  • userDetails() - Get details of a user with specific ID

    Method : GET Required Parameters - 'id' : ID of the user whose details are to be fetched


  Files folder image Files (5)  
File Role Description
Accessible without login Plain text file api.php Example API example script
Accessible without login Plain text file index.php Appl. Test page script
Accessible without login Plain text file README.md Doc. Documentation
Plain text file rest.php Class Class source
Accessible without login Plain text file update.php Appl. Test page script

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads  
 100%
Total:0
This week:0