Skip to content

Commit 764100e

Browse files
author
Milad Rahimi
committed
update readme
1 parent 4f74294 commit 764100e

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

README.md

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,19 @@ $router
7979
->get('/', function () {
8080
return '<b>GET method</b>';
8181
});
82-
->post('/', function () {
83-
return '<b>POST method</b>';
84-
});
85-
->patch('/', function () {
82+
->post('/', function () {
83+
return '<b>POST method</b>';
84+
});
85+
->patch('/', function () {
8686
return '<b>PATCH method</b>';
87-
});
88-
->put('/', function () {
89-
return '<b>PUT method</b>';
90-
});
91-
->delete('/', function () {
92-
return '<b>DELETE method</b>';
93-
})
94-
->dispatch();
87+
});
88+
->put('/', function () {
89+
return '<b>PUT method</b>';
90+
});
91+
->delete('/', function () {
92+
return '<b>DELETE method</b>';
93+
})
94+
->dispatch();
9595
```
9696

9797
You may want to use your custom http methods so take look at this example:
@@ -289,7 +289,7 @@ $router->post('/blog/posts', function (ServerRequest $request) {
289289
$post->title = $request->getQueryParams()['title'];
290290
$post->content = $request->getQueryParams()['content'];
291291
$post->save();
292-
292+
293293
return new EmptyResponse(201);
294294
});
295295

@@ -325,9 +325,9 @@ $router
325325
->get('/empty', function () {
326326
return new EmptyResponse();
327327
})
328-
->get('/empty', function () {
328+
->get('/empty', function () {
329329
return new EmptyResponse();
330-
})
330+
});
331331

332332
$router->dispatch();
333333

@@ -347,8 +347,7 @@ $router
347347
->get('/redirect', function () {
348348
return new RedirectResponse('https://miladrahimi.com');
349349
})
350-
->dispatch();
351-
350+
->dispatch();
352351
```
353352

354353
### More about HTTP Request and Response
@@ -451,19 +450,19 @@ use MiladRahimi\PhpRouter\Enums\GroupAttributes;
451450
$router = new Router();
452451

453452
$router->group(['prefix' => '/admin'], function (Router $router) {
454-
// URI: /admin/setting
453+
// URI: /admin/setting
455454
$router->get('/setting', 'AdminController@getSetting');
456455
});
457456

458457
$attributes = [
459-
'prefix' => '/products',
460-
'namespace' => 'App\Controllers',
461-
'domain' => 'shop.example.com',
462-
'middleware' => SampleMiddleware::class,
458+
'prefix' => '/products',
459+
'namespace' => 'App\Controllers',
460+
'domain' => 'shop.example.com',
461+
'middleware' => SampleMiddleware::class,
463462
];
464463

465464
$router->group($attributes, function (Router $router) {
466-
// URI: http://shop.example.com/products/{id}
465+
// URI: http://shop.example.com/products/{id}
467466
// Controller: App\Controllers\ShopController@getProduct
468467
// Domain: shop.example.com
469468
// Middleware: SampleMiddleware
@@ -538,7 +537,7 @@ $router->name('home')->get('/', function (Router $router) {
538537
"current_page_name" => $router->currentRoute()->getName() /* home */
539538
"current_page_uri" => $router->currentRoute()->getUri() /* /home */
540539
"current_page_method" => $router->currentRoute()->getMethod() /* GET */
541-
"current_page_domain" => $router->currentRoute()->getDomain() /* NULL */
540+
"current_page_domain" => $router->currentRoute()->getDomain() /* NULL */
542541
]);
543542
});
544543

0 commit comments

Comments
 (0)