Skip to content

ianfoose/php-api-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 

Repository files navigation

PHP Router

PHP API Router

Support

Supports:

  • GET
  • PUT
  • POST
  • DELETE
  • PATCH

for custom values, use all.

Use

Make sure include path is set to the location where you put the script.

include('Router.php');

Get,Post,Put,Patch,Delete

Router::get('/endpoint',function() {
  // todo
});

All methods

Router::all('/endpoint',function() {
  // todo
});

Other Functions

All code in the 'set' route executes before any other routes. This is a good place for CORS policys and/or authorization

Router::set('/',function() {
		// todo
});

Get routes

$routes = Router::getInstance()->routes;

Route Parsing Example

To process routes and run their functions, use a foreach loop, make sure you are accessing the singleton for the Router class or this will not work.

foreach(Router::getInstance()->routes as $key => $value) {
	echo $value['name'];
}

About

PHP API Router

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages