Skip to content

Build a complete RESTfull API in PHP including routing, user authentication and resource management

Notifications You must be signed in to change notification settings

ankain-lesly/Build-a-RestFull-API-in-PHP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build a RestFull API in PHP

This is working standard PHP restfull API setup application with routing system and user Authentication

Frontend --> React JS

Table of contents

Overview

Screenshots

Products fetch JSON Response

Single Product Display

Welcome! 👋

Hi, I am Lesly Chuo. Checking out this PHP Development Stack challenge.

This is working standard PHP restfull API setup application with routing system. It serves data in a Javascript Object Notation (JSON) format which could easily be integrated in any application. Object Oriented Programming with namespace system is highly in use includeing features such as.

Workflow

Using PHP namespace system to organize an import class object into API.php page for further validation

// Importing Class Obj
use App\Config\Router;
// use App\Config\ErrorHandler;
use App\Controllers\ProductController;
use App\Controllers\CategoryController;
use App\Controllers\UserController;
use App\Config\CustomErrorValidator;

Routing

Object Oriented Programming provides a variety of methods and approach to resolve a coding procedue. Making use of PHP associative arrays and call_user custom fuctions make this process quite interesting..

// Sample Rout Display
$routes = array(

// Products
	   "GET@/api/products/books"	=> 	[ProductController::class, 'index'],
	"DELETE@/api/products/books" 	=> 	[ProductController::class, 'delete'],	// delete_key, auth_key

	  "POST@/api/category/books"	=> 	[CategoryController::class, 'update'],	// key, name, author, is_read

     "POST@/api/create/category"	=> 	[CategoryController::class, 'create'],	// name, author

// User
         "POST@/api/user/signup"	=> 	[UserController::class, 'signup'],	    // signup user data

          "POST@/api/user/login"	=> 	[UserController::class, 'login'],		// login user data
          /* ... */
);

Here we get a route mapped to a controller class pointing to a specific method in execution.

Error Handling

Custom errors and exception handling to catch customize and return errors or exceptions when need be

User Authentication

Full featured user signup/login registration system with token authentication

Resource Management

User data control, profile, create products and category pages

My process

Development still in progress... I will be updating promply

Author

Complete rest API using pure objecti oriented PHP w

About

Build a complete RESTfull API in PHP including routing, user authentication and resource management

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published