/php-router

php-router

Primary LanguagePHP

Php Router

Clone this repository
git clone https://github.com/Pijushgupta/php-router.git
Adding it to the project
include_once 'Location of file';
OR use Composer/auto-loader
composer require pijush_gupta/php-router:dev-main
Using it in the project
use phpRouter\Router;
new Router('/', function () {
	echo 'Home';
});
Get method with Parameters
https://example.com?a=Pijush&b=Gupta
new Router('/',function($a,$b){ //exact number of variables and name as query vars from url.
	echo $a . $b;
})
Post method
https://example.com/
new Router('/',function($post){ //variable name for the param can be anything
	var_dump($post);
});