From 6f0ac0c82545a2a3d1ccf94703b3b1bc8f8ed93d Mon Sep 17 00:00:00 2001 From: Amirul islam <dev.amirul@gmail.com> Date: Sat, 11 Nov 2023 12:31:23 +0600 Subject: [PATCH 1/5] updated readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b05b794..b451fa1 100644 --- a/README.md +++ b/README.md @@ -147,8 +147,8 @@ $router->any($uri, $callback); Routes accept a URI and a closure or a array, providing a very simple and expressive method of defining routes and behavior without complicated routing configuration files. -1. First Create index.php file. -2. Define App root path. +1. First create index.php file. +2. Define Application root path. 3. Require vendor autoload file. 4. Create `router` singleton instance. 5. Define routes. From 0a63e2fc17a6f81bad5b7a53229424152e3bca15 Mon Sep 17 00:00:00 2001 From: Amirul islam <dev.amirul@gmail.com> Date: Sat, 11 Nov 2023 12:38:51 +0600 Subject: [PATCH 2/5] updated readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b451fa1..a3eb5b3 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,9 @@ A simple, lightweight, and powerful PHP Router with rich features like Middlewar ## Features: - Supports `GET` `POST` `PUT` `PATCH` and `DELETE` HTTPS verbs -- The methods that the router supports are - `get()` `post()` `put()` `patch()` `delete()` `match()` `any()` +- The methods that the router supports are :- `get()` `post()` `put()` `patch()` `delete()` `match()` `any()` - Named Routes -- Regular Expression Constraints for parameters +- Regular expression constraints for parameters - Fallback method - Middleware - CSRF protection From 98b79e6a5c6edac765c94dd040cf3e8d522e1a7d Mon Sep 17 00:00:00 2001 From: Amirul islam <dev.amirul@gmail.com> Date: Sat, 11 Nov 2023 13:11:48 +0600 Subject: [PATCH 3/5] updated readme --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a3eb5b3..4aa3825 100644 --- a/README.md +++ b/README.md @@ -384,6 +384,8 @@ $router->get('/profile/:id/user/:name?', function () { })->where(['id' => '^\d+$', 'name' => '^[a-zA-Z ]*$']); ``` +### match and any method + Sometimes you may need to register a route that responds to multiple HTTP verbs. You may do so using the match method. Or, you may even register a route that responds to all HTTP verbs using the any method: ```php @@ -408,13 +410,13 @@ $router->get('admin/*', function () { In the example above, you can dynamically use any path after `admin/`. The asterisk is used as a wildcard and matches any combination of characters. -### Redirect Routes: +<!-- ### Redirect Routes: If you are defining a route that redirects to another URI, you may use the `redirect()` method. This method provides a convenient shortcut so that you do not have to define a full route ```php $router->redirect('/here', '/there'); -``` +``` --> ## Middlewares: From 94500086f72ee88a22c04dd583587a18eb424f90 Mon Sep 17 00:00:00 2001 From: Amirul Islam Anirban <dev.amirul@gmail.com> Date: Sat, 11 Nov 2023 16:18:44 +0600 Subject: [PATCH 4/5] Update README.md --- README.md | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4aa3825..bc6a672 100644 --- a/README.md +++ b/README.md @@ -641,6 +641,40 @@ In Content file: </body> ``` +## Handle Form: + +```php +<form action="/login" method="POST" class="mt-5"> + + <?=setCsrf()?> + + <div class="mb-3"> + <label for="exampleInputEmail" class="form-label">Email address</label> + <input type="email" name="email" class="form-control" id="exampleInputEmail" aria-describedby="emailHelp"> + <div id="emailHelp" class="form-text"> <?= errors('email')?> </div> + </div> + + <div class="mb-3"> + <label for="exampleInputPassword" class="form-label">Password</label> + <input type="password" name="password" class="form-control" id="exampleInputPassword"> + <div id="emailHelp" class="form-text"> <?= errors('password')?> </div> + </div> + + <button type="submit" class="btn btn-primary">Login</button> +</form> +``` + +### Method Field: + +Since HTML forms can't make PUT, PATCH, or DELETE requests, you will need to add a hidden `_method` field to spoof these HTTP verbs. The `setMethod()` Blade directive can create this field for you: + +```php +<form> + <?=setMethod('delete')?> + ... +</form> +``` + ## Helpers: ### Table of Contents @@ -714,4 +748,4 @@ return redirect('/redirect-link'); Finds route by route name and redirect this route: ```php return toRoute('users'); -``` \ No newline at end of file +``` From 92fa1e0a8e9ca60ce69b9e2b99cd6d369234f2ed Mon Sep 17 00:00:00 2001 From: Amirul Islam Anirban <dev.amirul@gmail.com> Date: Sat, 11 Nov 2023 16:20:44 +0600 Subject: [PATCH 5/5] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index bc6a672..9b2f7b8 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ A simple, lightweight, and powerful PHP Router with rich features like Middlewar - **[Controllers](#Controllers)** - **[Request](#Request)** - **[Handle Html View Content File](#Handle-Html-View-Content-File)** +- **[Handle Form](#Handle-Form)** - **[Helpers](#Helpers)**