Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Milad Rahimi authored Nov 3, 2019
1 parent 4964fd2 commit 4ed59c2
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,20 +226,14 @@ In default, route parameters can match any value, but you can define regex patte
```php
use MiladRahimi\PhpRouter\Router;

class BlogController
{
function getPost(int $id)
{
return 'Content of the post: ' . $id;
}
}

$router = new Router();

// ID must be a numeric value
$router->define('id', '[0-9]+');

$router->get('/blog/post/{id}', 'BlogController@getPost');
$router->get('/blog/post/{id}', function($id) {
return $id;
});

$router->dispatch();
```
Expand Down Expand Up @@ -530,7 +524,7 @@ try {
} catch (RouteNotFoundException $e) {
$router->getPublisher()->publish(new EmptyResponse(404));
} catch (Throwable $e) {
// other exceptions...
// your controller exceptions...
}
```

Expand Down

0 comments on commit 4ed59c2

Please sign in to comment.