Skip to content

imjafran/php-routing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

DRIM PHP Route

Simple PHP Fast Routing for Small Web Application or Rest API .

DRIM is the abbreviation of Dispite Redicule It's Made . Basically its being published as an open source PHP Micro Framework . As far now, I'm publishing it's basic routing system .

Features

  1. Easy Deployment
  2. Fastest Routing
  3. Parameter Supports
  4. Request Handlier [GET, POST, PUT, DELETE, ANY]
  5. Redirecting
  6. Controller Forwarding

User Guide

How to use DRIM PHP Route

Understanding Route Structures

Route::METHOD(ROUTE, CALLBACK);

That means, a route should be like

Route::get("/", function(){
	echo "This is home page";	
});
Route::get("/contact", function(){
	echo "This is contact page";	
});
Using Parameter

You can use parameters . Follow this structure .

Route::get("/user/{id}", function($id){
	echo "This is user number " . $id;	
});

or

Route::get("/name/:myname", function($someName){
	echo "My name is " . $someName;	
});

Muliple Parameter shoule be like this

Route::get("/post/{user}/{post}", function($user, $post){	
	echo "Show the post number " . $post . " of " . $user . " user";	
});
Request Method

It supports request handling .

like if you are thinking to apply post method, just use method post for Route::post();

Route::post("/about/", function(){	
	echo "About Page";	
});

You can use 5 different method . The list is bellow

  1. GET
  2. POST
  3. PUT
  4. DELETE
  5. ANY

any method is basically cross of all method .

Examples:

Route::get("/about/", function(){	
	echo "About Page, only get request allow";	
});

Route::post("/about/", function(){	
	echo "About Page, only post request allow";	
});

Route::put("/about/", function(){	
	echo "About Page, only post put allow";	
});

Route::delete("/about/", function(){	
	echo "About Page, only post delete allow";	
});

Route::any("/about/", function(){	
	echo "About Page, all available requests are allowed";	
});
Directing

You can redirect any url to another .

Internal usage

Route::redirect('/here', '/there');

External usage

Route::redirect('/jafran', 'https://www.facebook.com/iamjafran');
Controller Forwarding

You can easily navigate your request to controller class .

Route::get('/test', 'yourController@test');

Here, yourController is a class in your controller folder and test is a method of this class .

You can just forward your controller to __construct method by justing not mentioning any method name .

Easy!

Route::get('/test', 'yourController');

.htaccess

the .htacccess file should be like this

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php [NC,L,QSA]

Contribution

The base developer is Jafran Hasan . The core contributors are... [awaiting]

See the websites based on this DRIM Routing System . www.btebresults.com

My project website : www.returnxero.com

Releases

No releases published

Packages

No packages published

Languages