anujsinghwd / anrouter
A simple and small routing library
dev-master
2018-03-29 03:59 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-09-29 06:25:38 UTC
README
A simple and small PHP Routing
Installation
composer require anujsinghwd/anrouter
Usage
-
First configure
.htaccess
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . index.php [L]
-
$anrouter = new AnRouter()
-
Simply make function according to your route
Example
- index.php File
require_once './lib/AnRouter.php'; $anrouter = new AnRouter(); $anrouter->get('method_name'); -> For GET REQUEST $anrouter->post('method_name'); -> For POST REQUEST $anrouter->put('method_name'); -> For PUT REQUEST $anrouter->delete('method_name'); -> For DELETE REQUEST function method_name() { echo "Method Called"; }
- Above route called by
(http://your_base_url/method_name)
Parameter Handling
- Pass with request
$anrouter->get('method_name', array('agr1' => $val))
- Getting the Parameter in function
function method_name($param) { echo $param; }