Skip to content

Commit 4ed59c2

Browse files
author
Milad Rahimi
authored
Update README.md
1 parent 4964fd2 commit 4ed59c2

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

README.md

+4-10
Original file line numberDiff line numberDiff line change
@@ -226,20 +226,14 @@ In default, route parameters can match any value, but you can define regex patte
226226
```php
227227
use MiladRahimi\PhpRouter\Router;
228228

229-
class BlogController
230-
{
231-
function getPost(int $id)
232-
{
233-
return 'Content of the post: ' . $id;
234-
}
235-
}
236-
237229
$router = new Router();
238230

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

242-
$router->get('/blog/post/{id}', 'BlogController@getPost');
234+
$router->get('/blog/post/{id}', function($id) {
235+
return $id;
236+
});
243237

244238
$router->dispatch();
245239
```
@@ -530,7 +524,7 @@ try {
530524
} catch (RouteNotFoundException $e) {
531525
$router->getPublisher()->publish(new EmptyResponse(404));
532526
} catch (Throwable $e) {
533-
// other exceptions...
527+
// your controller exceptions...
534528
}
535529
```
536530

0 commit comments

Comments
 (0)