https://github.com/jadob/router
https://github.com/jadob/router
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/jadob/router
- Owner: jadob
- Created: 2021-09-17T18:49:53.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2025-04-19T19:59:08.000Z (about 1 year ago)
- Last Synced: 2025-04-19T21:40:01.479Z (about 1 year ago)
- Language: PHP
- Size: 94.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
Awesome Lists containing this project
README
# jadob/router
## Routing component for Jadob Framework
### Getting Started
```php
//Creating and configuring router instance:
//defining routes:
$routes = [
'home' => [
'path' => '/', //required
'controller' => Your/App/Controller::class, //required
'action' => 'index' //not required
'ignore_global_prefix' => true //if true,
],
];
//if you need to add a set of routes with a common prefix:
$collection = new \Jadob\Router\RouteCollection();
$collection->setPrefix('/backend');
// this route will be matched on URI "/backend/posts/new"
$backendRoute = (new Route('backend_new_post'))
->setPath('/posts/new')
->setController(\Your\App\BackendController::class)
->setAction('newPost');
$collection->addRoute($backendRoute);
//when collection is passed to array, his key is ignored
$routes['backend_collection'] = $collection;
$routerConfig = [
'routes' => $routes
];
$router = new \Jadob\Router\Router($routerConfig);
````