{"id":15026687,"url":"https://github.com/nicollassilva/minasrouter","last_synced_at":"2025-04-09T20:21:41.854Z","repository":{"id":57026841,"uuid":"373993582","full_name":"nicollassilva/minasrouter","owner":"nicollassilva","description":"MinasRouter is simple, fast, and extremely readable for routes. Create and manage your routes in just a few steps.","archived":false,"fork":false,"pushed_at":"2022-05-03T20:25:51.000Z","size":165,"stargazers_count":14,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-23T22:13:32.073Z","etag":null,"topics":["middleware","mvc","php","php-library","php-router","php-router-standalone","php-routing","php74","php8","php80","restful","restful-api","router","routers","routing"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nicollassilva.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-05T01:14:16.000Z","updated_at":"2024-03-11T11:45:07.000Z","dependencies_parsed_at":"2022-08-23T16:20:38.366Z","dependency_job_id":null,"html_url":"https://github.com/nicollassilva/minasrouter","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicollassilva%2Fminasrouter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicollassilva%2Fminasrouter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicollassilva%2Fminasrouter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicollassilva%2Fminasrouter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nicollassilva","download_url":"https://codeload.github.com/nicollassilva/minasrouter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248104446,"owners_count":21048339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["middleware","mvc","php","php-library","php-router","php-router-standalone","php-routing","php74","php8","php80","restful","restful-api","router","routers","routing"],"created_at":"2024-09-24T20:04:53.569Z","updated_at":"2025-04-09T20:21:41.805Z","avatar_url":"https://github.com/nicollassilva.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Router @MinasRouter\n\n![a](https://user-images.githubusercontent.com/10711363/121407187-6b904a00-c935-11eb-84a0-5fae3d7a9deb.PNG)\n\n[![Maintainer](http://img.shields.io/badge/maintainer-@nicollassilva-blue.svg?style=flat-square)](https://github.com/nicollassilva)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/nicollassilva/minasrouter/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/nicollassilva/minasrouter/?branch=master)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)\n[![Latest Version](https://img.shields.io/github/release/nicollassilva/minasrouter.svg?style=flat-square)](https://github.com/nicollassilva/minasrouter/releases)\n[![Build Status](https://scrutinizer-ci.com/g/nicollassilva/minasrouter/badges/build.png?b=master)](https://scrutinizer-ci.com/g/nicollassilva/minasrouter/build-status/master)\n[![Code Intelligence Status](https://scrutinizer-ci.com/g/nicollassilva/minasrouter/badges/code-intelligence.svg?b=master)](https://scrutinizer-ci.com/code-intelligence)\n\n#### MinasRouter is simple, fast and extremely readable for routes. Create and manage your routes in just a few steps.\n\n\u003e Simples, rápido e MUITO funcional. **MinasRouter** é um componente de rotas PHP para projetos MVC! Foi feito para abstrair os verbos RESTfull `(GET, POST, PUT, PATCH, DELETE)` e renderizar de forma simples e fácil no controller da aplicação.\n\n\u003e `MinasRouter` trabalha e processa todas as informações de forma isolada, facilitando o processo para o desenvolvedor e acelerando o desenvolvimento/andamento do projeto.\n\nSimple, fast and VERY functional. **MinasRouter** is a PHP routes component for MVC projects! It is designed to abstract the RESTfull (GET, POST, PUT, PATCH, DELETE) verbs and render them simply and easily in the application controller.\n\n**MinasRouter** works and processes all information in isolation, facilitating the process for the developer and accelerating the development/progress of the project.\n\n# Highlights @MinasRouter\n\n- In a few minutes you can create routes for your application or api `(Yes, it really is a few minutes)`\n- Fast and Easy middleware system\n- Respect the RESTfull verbs and has great functions to deal with them\n- Route customization, regex in dynamic parameters and optional parameters\n- Spoofing for verbalization and data control (FormSpoofing)\n- Carries dynamic parameters to controller arguments \n- Easy routing groups and fast create\n- It has a **Request Class** to control and work with route data\n\n\u003e With **two lines** you start using routes!\n\n# Application example\n\nMaybe you are a person who learns by watching, you can access the [example](https://github.com/nicollassilva/minasrouter/tree/master/example) folder, which contains an folders architecture example of how we use MinasRouter.\n\n# Tests\n\n\u003e You can check all tests done [here](https://github.com/nicollassilva/minasrouter/tree/master/tests).\n\u003e Enjoy!\n\n# Installation\n\nMinasRouter is available via `Composer require`:\n\n```json\n\"require\" {\n    \"nicollassilva/minasrouter\": \"^1.0\"\n}\n```\nor run in **terminal**:\n\n```sh\ncomposer require nicollassilva/minasrouter\n```\n\n# Documentation\n\n### 1. Configuration\n- [Redirect to Public Folder](https://github.com/nicollassilva/minasrouter#redirect-to-public-folder)\n* **Public Folder Configuration**\n- [Apache](https://github.com/nicollassilva/minasrouter#apache)\n- [Nginx](https://github.com/nicollassilva/minasrouter#apache)\n### 2. Routes\n- [My first Route](https://github.com/nicollassilva/minasrouter#the-first-route)\n- [RESTfull Verbs](https://github.com/nicollassilva/minasrouter#restfull-verbs)\n* **Customization**\n- [Named Routes](https://github.com/nicollassilva/minasrouter#named-routes)\n- [Dynamic Parameters (Required and Optional)](https://github.com/nicollassilva/minasrouter#dynamic-parameters-required-and-optional)\n- [Validating a Dynamic Parameter](https://github.com/nicollassilva/minasrouter#validating-a-dynamic-parameter)\n* **Middlewares**\n- [Set Global Middlewares](https://github.com/nicollassilva/minasrouter#set-global-middlewares)\n- [Attach in a route](https://github.com/nicollassilva/minasrouter#attach-in-a-route)\n- [Delete a middleware](https://github.com/nicollassilva/minasrouter#delete-a-middleware)\n* **Route Groups**\n- [All Methods](https://github.com/nicollassilva/minasrouter#route-groups)\n- [Named Group](https://github.com/nicollassilva/minasrouter#named-group)\n- [Prefixed Group](https://github.com/nicollassilva/minasrouter#prefixed-group)\n- [Default Namespace Group](https://github.com/nicollassilva/minasrouter#default-namespace-group)\n- [Default Middleware Group](https://github.com/nicollassilva/minasrouter#default-middleware-group)\n- [Nested Group Methods](https://github.com/nicollassilva/minasrouter#nested-group-methods)\n* **Others**\n- [Route Redirect](https://github.com/nicollassilva/minasrouter#route-redirect)\n- [Route with Individual Middleware in Group](https://github.com/nicollassilva/minasrouter#route-with-individual-middleware-in-group)\n- [Route with Different Name in Group](https://github.com/nicollassilva/minasrouter#route-with-different-name-in-group)\n- [Fallback Routes](https://github.com/nicollassilva/minasrouter#fallback-routes)\n\n### 3. Request Route\n- [Introduction](https://github.com/nicollassilva/minasrouter#request-route)\n* **Methods**\n- [Request Path](https://github.com/nicollassilva/minasrouter#retrieving-the-request-path)\n- [Request URL](https://github.com/nicollassilva/minasrouter#retrieving-the-request-url)\n- [Request Headers](https://github.com/nicollassilva/minasrouter#request-headers)\n- [Request IP Address](https://github.com/nicollassilva/minasrouter#request-ip-address)\n- [Retrieving Data](https://github.com/nicollassilva/minasrouter#retrieving-data)\n- [Request Method](https://github.com/nicollassilva/minasrouter#retrieving-the-request-method)\n\n# Introduction\n\n\u003e Para começar a usar o MinasRouter, todo o gerenciamento da navegação deverá ser redirecionado para o arquivo padrão de rotas do seu sistema, que fará todo o processo de tratamento das rotas e retornará o que foi por padrão configurado. Configure conforme os exemplos abaixo e de acordo com seu servidor.\n\nTo start using MinasRouter, all navigation management must be redirected to your system's default route file, which will do the entire route handling process and return what was configured by default.\nConfigure according to the examples below and according to your server.\n\n## Redirect to Public Folder\n\n```apacheconf\nRewriteEngine on\nOptions All -Indexes\n\nRewriteCond %{HTTPS} on\nRewriteCond %{HTTP_HOST} (www\\.)?localhost\nRewriteRule (.*) https://%{HTTP_HOST} [L,R=301]\n\nRewriteCond %{REQUEST_URI} !public/\nRewriteRule (.*) /public/$1 [L]\n```\n\n### apache\n\n```apacheconf\nRewriteEngine On\n#Options All -Indexes\n\n# Handle Authorization Header\nRewriteCond %{HTTP:Authorization} .\nRewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]\n\n# URL Rewrite\nRewriteCond %{SCRIPT_FILENAME} !-f\nRewriteCond %{SCRIPT_FILENAME} !-d\nRewriteRule ^(.*)$ index.php?route=/$1 [L,QSA]\n\n### Do not use the settings below if you are using developing in a local environment, use only in production.\n\n## WWW Redirect\n#RewriteCond %{HTTP_HOST} !^www\\. [NC]\n#RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n\n## HTTPS Redirect\n#RewriteCond %{HTTP:X-Forwarded-Proto} !https\n#RewriteCond %{HTTPS} off\n#RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n\n```\n\n### nginx\n\n```nginx\nlocation / {\n  if ($script_filename !~ \"-f\"){\n    rewrite ^(.*)$ /index.php?route=/$1 break;\n  }\n}\n```\n\n# The first Route\n\nTo start the components:\n\n```php\n\u003c?php\n    require __DIR__ . \"/../vendor/autoload.php\";\n    \nuse MinasRouter\\Router\\Route;\n\n// The second argument is optional. It separates the Controller and Method from the string\n// Example: \"Controller@method\"\nRoute::start(\"http://yourdomain.com\", \"@\");\n\nRoute::get(\"/\", function() {\n    // ...\n});\n\n// ... all routes here\n\n// You will put all your routes before this function\nRoute::execute();\n```\n\n### RESTfull Verbs\n\nMethods:\n\n| Function |     Parameter    | Parameter   | Parameter |\n|:--------:|:----------------:|-------------|-----------|\n|    get   |    String $uri   |  $callback  |           |\n|   post   |    String $uri   |  $callback  |           |\n|    put   |    String $uri   |  $callback  |           |\n|   patch  |    String $uri   |  $callback  |           |\n|  delete  |    String $uri   |  $callback  |           |\n|   match  | Array $httpVerbs | String $uri | $callback |\n|    any   |    String $uri   |  $callback  |           |\n\nExample:\n\n```php\nRoute::get('/users', [\\App\\Controllers\\User::class, 'index']);\nRoute::post('/users', [\\App\\Controllers\\User::class, 'store']);\nRoute::put('/users/{id}', [\\App\\Controllers\\User::class, 'update']);\nRoute::patch('/users/{id}', [\\App\\Controllers\\User::class, 'update']);\nRoute::delete('/users/{id}', [\\App\\Controllers\\User::class, 'delete']);\n\n// The router allows you to register routes that respond to any HTTP verb:\nRoute::any('/', function() {\n    // ...\n});\n\n// Sometimes you may need to register a route that responds to multiple HTTP verbs:\nRoute::match([\"GET\", \"POST\"], \"/\", function() {\n    // ...\n});\n```\n\n### Named routes\n\nMethods:\n\n| Function |   Parameter  |\n|:--------:|:------------:|\n|   name   | String $name |\n|    as    | String $name |\n\nExample:\n\n```php\nRoute::get(\"/users/create\", function() {\n    // ...\n})-\u003ename(\"user.create\");\n\nRoute::get(\"/users/2\", function() {\n    // ...\n})-\u003eas(\"user.show\");\n```\n\n### Dynamic parameters (required and optional)\n\n```php\nRoute::get(\"/\", function() {\n    // ...\n})-\u003ename(\"web.index\");\n\nRoute::get(\"/user/{id}\", function($id) {\n    echo $id;\n})-\u003ename(\"user.show\");\n\nRoute::get(\"/post/{id?}\", function($id) {\n    if(!$id) {\n        // ...\n    }\n    \n    // ...\n})-\u003ename(\"post.show\");\n```\n\n### Validating a dynamic parameter\n\nMethods:\n\n|      Function     |   Parameter   | Parameter     |\n|:-----------------:|:-------------:|---------------|\n|       where       | Array $params |               |\n|     whereParam    | String $param | String $regex |\n|    whereNumber    | String $param |               |\n|     whereAlpha    | String $param |               |\n| whereAlphaNumeric | String $param |               |\n|     whereUuid     | String $param |               |\n\nExample:\n\n```php\nRoute::get(\"/user/{id}\", [\\App\\Controllers\\UserController::class, \"show\"])\n    -\u003ename(\"user.show\")\n    -\u003ewhere([\"id\" =\u003e \"[0-9]+\"]);\n\n// whereParam is alias of where method\nRoute::get(\"/profile/{slug}\", [\\App\\Controllers\\UserController::class, \"profile\"])\n    -\u003ename(\"user.profile\")\n    -\u003ewhereParam(\"id\", \"[0-9]+\");\n\nRoute::get(\"/book/{id}\", [\\App\\Controllers\\BookController::class, \"show\"])\n    -\u003ename(\"book.show\")\n    -\u003ewhereNumber(\"id\");\n```\n\n# Middlewares\n\nWorking with middlewares around here is pretty easy, we just need to pass the full names of the classes or set them as global, and from there, we use their alias.\n\n### Set Global Middlewares\n\n**OBS: It is important that you place all routes below. Routes above this class will not have these middlewares as global.**\n\n```php\nRoute::globalMiddlewares([\n    'isLogged' =\u003e \\App\\Middlewares\\isLogged::class,\n    'isAdmin' =\u003e \\App\\Middlewares\\isAdmin::class\n]);\n\n// ... all routes\n```\n\n### Attach in a route\n\nYou may use the middleware method to assign middleware to a route.\n\n```php\nRoute::get(\"/musics\", function() {\n    // ...\n})-\u003emiddleware(\"isLogged\");\n\nRoute::get(\"/musics\", function() {\n    // ...\n})-\u003emiddleware([\"isLogged\"]);\n```\n\nYou may assign multiple middleware to the route by passing an array of middleware names to the middleware method.\n\n```php\nRoute::get(\"/musics\", function() {\n    // ...\n})-\u003emiddleware(\"first, second\");\n\nRoute::get(\"/movies\", function() {\n    // ...\n})-\u003emiddleware([\"first\", \"second\"]);\n```\n\nWhen assigning middleware, you may also pass the fully qualified class name:\n\n```php\nuse App\\Middlewares\\VerifyCsrfToken;\n\nRoute::get(\"/series\", function() {\n    // ...\n})-\u003emiddleware(VerifyCsrfToken::class);\n\nRoute::get(\"/series\", function() {\n    // ...\n})-\u003emiddleware(App\\Middlewares\\VerifyCsrfToken::class);\n```\n\n### Delete a middleware\n\nSometimes you create a group of routes with middleware, but you want only one or a few routes to be without a specific middleware, you can do that.\n\n```php\nRoute::middleware(['auth', 'api'])-\u003egroup(function() {\n    Route::get('/', function() {\n        // All middlewares will works in this route\n    });\n    \n    Route::get('/no-api', function() {\n        // Only the auth middleware works here\n    })-\u003ewithoutMiddleware('api');\n});\n```\n\n# Route Groups\n\nAll methods:\n\n|  Function  |      Parameter      | ::function | -\u003efunction |\n|:----------:|:-------------------:|:----------:|:----------:|\n|  namespace |  String $namespace  |     Yes    |     Yes    |\n|   prefix   |    String $prefix   |     Yes    |     Yes    |\n|    name    |     String $name    |     Yes    |     Yes    |\n| middleware | String $middlewares |     Yes    |     Yes    |\n\n\u003e Group methods can be called static way or normal, **don't forget to call a function group** to insert as routes inside the closure.\n\nExamples:\n\n### Named group\n\n```php\nRoute::name(\"admin.\")-\u003egroup(function() {\n    Route::get(\"/\", function() {\n        // admin.index\n    })-\u003ename(\"index\");\n});\n```\n\n### Prefixed group\n\n```php\nRoute::prefix(\"admin/\")-\u003egroup(function() {\n    Route::get(\"/index\", function() {\n        // http://localhost/admin/index\n    })-\u003ename(\"index\");\n});\n```\n\n### Default namespace group\n\n```php\nRoute::namespace(\"App\\Controllers\")-\u003egroup(function() {\n    Route::get(\"/user/{id}\", [\"User\", \"show\"])-\u003ename(\"show\");\n    // \\App\\Controllers\\User\n});\n```\n\n### Default Middleware group\n\n```php\nRoute::middleware(\\App\\Middlewares\\isLogged::class)-\u003egroup(function() {\n    Route::get(\"/user/{id}\", [\"User\", \"show\"])-\u003ename(\"show\");\n});\n```\n\n### Nested group methods\n\n```php\nRoute::namespace(\"App\\Controllers\\Admin\")\n    -\u003emiddleware([\"isLogged\", \"isAdmin\"])\n    -\u003ename(\"admin.\")\n    -\u003eprefix(\"admin\")\n    -\u003egroup(function() {\n    // ...\n});\n```\n\n# Others\n\n### Route with Individual Middleware in group\n\nYou can use routes with individual middlewares within a route group.\n\n```php\nRoute::namespace(\"isLogged\")-\u003egroup(function() {\n    Route::get(\"/posts\", function() {\n        // ...\n    })-\u003emiddleware(\"isAdmin\");\n    \n    // ...\n});\n```\n\n### Route with Different name in group\n\nMaybe you are wanting a route where you ignore the group name, you can use the second parameter of the name method for that.\n\n```php\nRoute::name(\"admin.\")-\u003egroup(function() {\n    Route::get(\"/posts\", function() {\n        // name: app.posts\n    })-\u003ename(\"app.posts\", true);\n});\n```\n\n### Route redirect\n\nMethods:\n\n|      Function     |  Parameter  | Parameter        | Parameter             |\n|:-----------------:|:-----------:|------------------|-----------------------|\n|      redirect     | String $uri | String $redirect | Int $statusCode = 302 |\n| permanentRedirect | String $uri | String $redirect |                       |\n\nExample:\n\n```php\n// Returns 302 status code by default.\nRoute::redirect(\"/here\", \"/there\");\n\nRoute::redirect(\"/here\", \"/there\", 301);\n\n// permanentRedirect always returns 301\nRoute::permanentRedirect(\"/here\", \"/there\");\n\n// You can return an existing route\nRoute::redirect(\"/index\", \"web.index\");\n```\n\n### Fallback Routes\n\nThe fallback route is responsible when there is no route registered with that url address. Whenever there is no route that was requested by the user, the fallback route will be called.\n\n```php\nRoute::fallback(function() {\n    echo 'Route error!';\n    // ...\n});\n```\n\n\u003e OBS: Tenha cuidado caso queira redirecionar para uma rota existente, se nela conter argumentos dinâmicos, ela retornará todo o regex e irá causar erro.\n\nBe careful you redirect to an existing route, because if it has dynamic arguments, it will return the entire regex and error returned.\n\n# Request Route\n\nEach time the route is called and the Closure or controller method is called, you will have as a parameter an instance of \\MinasRouter\\Http\\Request. If the route has dynamic parameters (mandatory or optional), they need to be passed before receiving the Request instance.\n\n|  Function |        Parameter       |     Parameter    |\n|:---------:|:----------------------:|:----------------:|\n| getParams |                        |                  |\n|    path   |                        |                  |\n|    url    |                        |                  |\n|  fullUrl  |                        |                  |\n|   header  |     String $header     |  String $default |\n| hasHeader |     String $header     |                  |\n|     ip    |                        |                  |\n|   query   |     ?String $query     | ?String $default |\n|    all    |     ?String $except    |                  |\n| getMethod |                        |                  |\n|  isMethod | String $expectedMethod |                  |\n\nThe dynamic parameters of the route are directly passed in the method together with a instance of Request.\n\nExample:\n\n```php\nuse \\MinasRouter\\Http\\Request;\n\nRoute::get(\"/\", function(Request $request)) {\n   // ... \n});\n\nRoute::get(\"/user/{id}\", function($id, Request $request)) {\n   // ... \n});\n\nRoute::get(\"/posts/{slug?}\", function($slug, Request $request)) {\n   // ... \n});\n\nRoute::get(\"/book/{slug}\", function($slug, Request $request) {\n    // Retrieving all dynamic parameters\n    print_r($request-\u003egetParams());\n});\n\n```\n\nThe Request method is the method that has all your form data, query parameters, dynamic route parameters, and the entire request header.\n\n# Request Methods\n\n### Retrieving The Request Path\n\nThe **path** method returns the request's path information. So, if the incoming request is targeted at **http://localhost/foo/bar**, the path method will return **foo/bar**:\n\n```php\n$uri = $request-\u003epath();\n```\n\n### Retrieving The Request URL\n\nTo retrieve the full URL for the incoming request you may use the **url** or **fullUrl** methods. The **url** method will return the URL without the query string, while the **fullUrl** method includes the query string:\n\n```php\n$url = $request-\u003eurl();\n\n$urlWithQueryString = $request-\u003efullUrl();\n```\n\n### Request Headers\n\nYou may retrieve a request header from the **\\MinasRouter\\Http\\Request** instance using the header method. If the header is not present on the request, null will be returned. However, the header method accepts an optional second argument that will be returned if the header is not present on the request:\n\n```php\n$value = $request-\u003eheader(\"Header-Name\");\n\n$value = $request-\u003eheader(\"Header-Name\", \"default\");\n```\n\nThe **hasHeader** method may be used to determine if the request contains a given header:\n\n```php\nif ($request-\u003ehasHeader(\"Header-Name\")) {\n    // ...\n}\n```\n\nThe **bearerToken** method may be used to retrieve a bearer token from the Authorization header. If no such header is present, null will be returned.\n\n```php\n$token = $request-\u003ebearerToken();\n```\n\n### Request IP Address\n\nThe **ip** method may be used to retrieve the IP address of the client that made the request to your website:\n\n```php\n$ipAddress = $request-\u003eip();\n```\n\n### Retrieving Data\n\nThe **query** method will only retrieve values from the query string:\n\n```php\n$id = $request-\u003equery(\"id\");\n```\n\nIf the requested query string value data is not present, the second argument to this method will be returned:\n\n```php\n$developer = $request-\u003equery(\"developer\", \"Nicollas\");\n```\n\nYou may call the query method without any arguments in order to retrieve all of the query string values.\n\n```php\n$query = $request-\u003equery();\n```\n\nYou can access queryString's and input data directly, how properties of the Request class.\n\n```php\n// http://localhost/?foo=bar\n\n$foo = $request-\u003efoo;\n\n// \u003cinput type=\"text\" name=\"title\" value=\"MinasRouter\"\u003e\n\n$title = $request-\u003etitle;\n```\n\nYou may retrieve all of the incoming request's input data as an array using the all method. This method may be used regardless of whether the incoming request is from an HTML form or is an XHR request. If you want to nullify some data, you can pass it as a second parameter.\n\n```php\n$data = $request-\u003eall();\n\n// all, except csrf_token, page\n$data = $request-\u003eall(\"csrf_token, page\");\n```\n\n### Retrieving The Request Method\n\nThe **getMethod** method will return the HTTP verb for the request. You may use the **isMethod** method to verify that the HTTP verb matches a given string:\n\n```php\n$httpMethod = $request-\u003egetMethod();\n\nif ($request-\u003eisMethod('POST')) {\n    // ...\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicollassilva%2Fminasrouter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnicollassilva%2Fminasrouter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicollassilva%2Fminasrouter/lists"}