| Recommend this page to a friend! | 
|  Download | 
| Info | Example |  Files |  Install with Composer |  Download | Reputation | Support forum | Blog | Links | 
| Ratings | Unique User Downloads | Download Rankings | ||||
| Not yet rated by the users | Total: 130 | All time:  9,364 This week: 455  | ||||
| Version | License | PHP version | Categories | |||
| easy-router 1.0.0 | MIT/X Consortium ... | 5 | HTTP, PHP 5, Language, Design Patterns | 
| Description | Author | |
| This package can handle requests with controllers for given routes. | 
This is a simple class for you to start working with routes in your applications.
Install the latest version with
$ composer require laudirbispo/easy-route
<?php
use laudirbispo\EasyRouter\EasyRouter;
use laudirbispo\EasyRouter\Exceptions\RouterException;
$router = new EasyRouter();
/
 * @param $pattern - string|array routes - accept multiple routes
 * @param $calback - class with method string|closure
 */
$router->add($pattern, $callback);
//Examples
$router->add(
    ['/admin/login', '/admin/login?(.*)'], 
    'app\IdentityAccess\Application\Controllers\AccountController::pageLogin'
);
// (.*) that is to say that it accepts any parameter after "?"
// example - /admin/login?return=other_url
 
// Closures and Regular expressions
$router->add(['/admin/users/group/edit/([-\w]{36}$)'], function ($groupId){
  $controller = new app\IdentityAccess\Application\Controllers\AdminGroups;
  $controller->pageEditGroup($groupId);
});
// For example, this regular expression, accepts only string in the format "4d428391-8975-4158-b68a-9e3054e3df2c" 
// "4d428391-8975-4158-b68a-9e3054e3df2c" is uuid4 string
// Other example
$router->add('news/(\w+)/(\d+)', function($category, $year){
  $controller = new app\News\Application\Controllers\News;
  $controller->getNewsByYear($category, $year);
});
// Check if router exists
$router->has(string $pattern);
// Execute 
$router->execute($_SERVER['REQUEST_URI']);
// Exeptions 
// RouterException
// ControllerDoesNotExists
// InvalidRoute
// MethodDoesNotExists
// RouteNotFound
Laudir Bispo - <[email protected]> - <https://twitter.com/laudir_bispo><br />
EasyRouter is licensed under the MIT License - see the LICENSE file for details
Free Software, Hell Yeah!
|  Files (8) | 
| File | Role | Description | ||
|---|---|---|---|---|
|  src (1 file, 1 directory) | ||||
|    composer.json | Data | Auxiliary data | ||
|    README.md | Example | Example script | ||
|  Files (8) | / | src | / | Exceptions | 
| File | Role | Description | 
|---|---|---|
|  ControllerDoesNotExists.php | Class | Class source | 
|  InvalidRoute.php | Class | Class source | 
|  MethodDoesNotExists.php | Class | Class source | 
|  RouteNotFound.php | Class | Class source | 
|  RouterException.php | Class | Class source | 
| The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. | 
|  Install with Composer | 
|  | easy-router-2019-02-26.zip 5KB | 
|  | easy-router-2019-02-26.tar.gz 2KB | 
|  | Install with Composer | 
| Needed packages | ||
| Class | Download | Why it is needed | Dependency | 
|---|---|---|---|
| Get PHP Class Name |  .zip  .tar.gz | get controller name and namespace | Required | 
| Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
| 100% | 
 | 
 | 
| Applications that use this package | 
 If you know an application of this package, send a message to the author to add a link here.
 If you know an application of this package, send a message to the author to add a link here.