My older regex-based router.
Go to file
2018-03-12 16:58:57 +01:00
.htaccess Better readme and improved comments 2018-03-12 16:49:55 +01:00
index.php Removed nasty Config class 2018-03-12 16:58:57 +01:00
README.md Better readme and improved comments 2018-03-12 16:49:55 +01:00
Route.php Removed nasty Config class 2018-03-12 16:58:57 +01:00

Simple PHP Router

Hey! This is a simple class that can handel the whole url routing for your project.

It utilizes RegExp and PHPs anonymous functions to create a lightweight and fast routing system.

Take a look in the index.php file. As you can see the Route::add() method is used to add new routes to your project. The first argument takes the path segment. You can also use RegExp in there to parse out variables. All matches will be pushed to the handler method. The handler is the second argument of the add function.

Example:

Route::add('/user/(.*)/edit',function($id){
	//Do something
	echo 'Edit user with id '.$id.'<br/>';
});

Something dows not work?

Dont forget to set the basepath in your index.php and .htaccess file.