PHPackages                             needinfo/router - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. needinfo/router

ActiveLibrary[Framework](/categories/framework)

needinfo/router
===============

Um roteador PHP simples, seguro e robusto criado para agilidade na abstração MVC através de verbos RESTful.

2.0.0(2mo ago)12MITPHPPHP &gt;=8.1

Since Apr 4Pushed 2mo agoCompare

[ Source](https://github.com/needinfobr/router)[ Packagist](https://packagist.org/packages/needinfo/router)[ Docs](https://github.com/needinfobr/router)[ RSS](/packages/needinfo-router/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (3)Used By (0)

Needinfo Router
===============

[](#needinfo-router)

###### Small, simple and uncomplicated. The router is a PHP route components with abstraction for MVC. Prepared with RESTfull verbs (GET, POST, PUT, PATCH and DELETE), works on its own layer in isolation and can be integrated without secrets to your application.

[](#small-simple-and-uncomplicated-the-router-is-a-php-route-components-with-abstraction-for-mvc-prepared-with-restfull-verbs-get-post-put-patch-and-delete-works-on-its-own-layer-in-isolation-and-can-be-integrated-without-secrets-to-your-application)

Pequeno, simples e descomplicado. O router é um componentes de rotas PHP com abstração para MVC. Preparado com verbos RESTfull (GET, POST, PUT, PATCH e DELETE), trabalha em sua própria camada de forma isolada e pode ser integrado sem segredos a sua aplicação.

###### Needinfo is a set of small and optimized PHP components for common tasks. With them you perform routine tasks with fewer lines, writing less and doing much more.

[](#needinfo-is-a-set-of-small-and-optimized-php-components-for-common-tasks-with-them-you-perform-routine-tasks-with-fewer-lines-writing-less-and-doing-much-more)

Needinfo é um conjunto de pequenos e otimizados componentes PHP para tarefas comuns. Com eles você executa tarefas rotineiras com poucas linhas, escrevendo menos e fazendo muito mais.

- Router class with all RESTful verbs (Classe router com todos os verbos RESTful)
- **\[NEW no v2.0\]** Regex Constraints nos parâmetros de URL
- **\[NEW no v2.0\]** Retorno `405 Method Not Allowed` estruturado (+ Allow Headers)
- **\[NEW no v2.0\]** Encadeamento de Rotas (`->name()`, `->middleware()`, `->with()`)
- **\[NEW no v2.0\]** Matcher Desacoplado para uso focado em Frameworks que precisam ingerir uma Request customizada (Injeção de PSR-11 support).
- Optimized dispatch with total decision control (Despacho otimizado com controle total de decisões)
- Composer ready and PSR-4 compliant (Pronto para o composer e compatível com PSR-4)

Installation
------------

[](#installation)

Router is available via Composer:

```
composer require needinfobr/router "^2.0"
```

Documentation
-------------

[](#documentation)

###### For details on how to use the router, see the sample folder with details in the component directory. To use the router you need to redirect your route routing navigation (index.php) where all traffic must be handled. The example below shows how:

[](#for-details-on-how-to-use-the-router-see-the-sample-folder-with-details-in-the-component-directory-to-use-the-router-you-need-to-redirect-your-route-routing-navigation-indexphp-where-all-traffic-must-be-handled-the-example-below-shows-how)

Para mais detalhes sobre como usar o router, veja a pasta de exemplo com detalhes no diretório do componente. Para usar o router é preciso redirecionar sua navegação para o arquivo raiz de rotas (index.php) onde todo o tráfego deve ser tratado.

#### Apache (`.htaccess`)

[](#apache-htaccess)

```
RewriteEngine On
#Options All -Indexes

## ROUTER URL Rewrite
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?route=/$1 [L,QSA]
```

#### Nginx

[](#nginx)

```
location / {
    if ($script_filename !~ "-f"){
        rewrite ^(.*)$ /index.php?route=/$1 break;
    }
}
```

### 1. Basic usage and MVC Pattern

[](#1-basic-usage-and-mvc-pattern)

```
