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 .
- Easy Deployment
- Fastest Routing
- Parameter Supports
- Request Handlier [GET, POST, PUT, DELETE, ANY]
- Redirecting
- Controller Forwarding
How to use DRIM PHP Route
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";
});
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";
});
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
- GET
- POST
- PUT
- DELETE
- 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";
});
You can redirect any url to another .
Internal usage
Route::redirect('/here', '/there');
External usage
Route::redirect('/jafran', 'https://www.facebook.com/iamjafran');
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');
the .htacccess
file should be like this
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php [NC,L,QSA]
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