-
Notifications
You must be signed in to change notification settings - Fork 1
Router
This framework has a sleek routing system which has support for the following HTTP verbs namely, GET, POST, PUT,PATCH and DELETE. It also has support for dynamic routing e.g /test/{id} where the value of id can be anything.
public static function get(string $url, $controllerDatas)
This method is used for making GET requests, it can be accessed in the following ways,
use App\Systems\Router;
use App\Systems\Request;
Router::get('/','HomeController@index');
OR
Router::get('/',function(){
echo "I am here";
});
OR
Router::get('/demo/{id}',function(Request $request){
echo $request->get('id');
});
public static function post(string $url, $controllerDatas)
This method is used for making POST requests, it can be accessed in the following ways,
use App\Systems\Router;
use App\Systems\Request;
Router::post('/data','HomeController@postData');
OR
Router::post('/demo/{id}',function(Request $request){
echo $request->get('id');
});
public static function put(string $url, $controllerDatas)
This method is for making PUT requests, it can be accessed in the following ways,
use App\Systems\Router;
use App\Systems\Request;
Router::put('/data/1','HomeController@postData');
OR
Router::put('/demo/{id}',function(Request $request){
//Input your logic here
});
public static function patch(string $url, $controllerDatas)
This method is for making PATCH requests, it can be accessed in the following ways,
use App\Systems\Router;
use App\Systems\Request;
Router::patch('/data/1','HomeController@postData');
OR
Router::patch('/demo/{id}',function(Request $request){
//Input your logic here
});
public static function delete(string $url, $controllerDatas)
This method is for making DELETE requests, it can be accessed in the following ways,
use App\Systems\Router;
use App\Systems\Request;
Router::delete('/data/1','HomeController@postData');
OR
Router::delete('/demo/{id}',function(Request $request){
//Input your logic here
});
Made with love in Naija