PHPackages                             workcode/wcrouter - 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. workcode/wcrouter

ActiveLibrary[Framework](/categories/framework)

workcode/wcrouter
=================

A classic WorkCode Router is easy, fast and extremely uncomplicated. Create and manage your routes in minutes!

v1.0.0(2y ago)07MITPHPPHP &gt;=7.2

Since Jan 22Pushed 2y ago1 watchersCompare

[ Source](https://github.com/denislumerk/wcrouter)[ Packagist](https://packagist.org/packages/workcode/wcrouter)[ Docs](http://www.innovatistech.com.br)[ RSS](/packages/workcode-wcrouter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Router @WorkCode
================

[](#router-workcode)

[![Maintainer](https://camo.githubusercontent.com/19ab08c4183d53e3cdd11f9d106ed5f2548feab31e3ce6415810948192de16e1/687474703a2f2f696d672e736869656c64732e696f2f62616467652f6d61696e7461696e65722d4064656e69736c756d65726b2d626c75652e7376673f7374796c653d666c61742d737175617265)](https://instagram.com/denislumerk)[![Source Code](https://camo.githubusercontent.com/a153f32b877dad574096b4bde22acbcf52b47e6a3306f68e68e632446269878e/687474703a2f2f696d672e736869656c64732e696f2f62616467652f736f757263652d776f726b636f64652f7763726f757465722d626c75652e7376673f7374796c653d666c61742d737175617265)](https://github.com/denislumerk/wcrouter)[![PHP from Packagist](https://camo.githubusercontent.com/0d115290be231327a74844722ad85df141e15dcfb2132830bf669158fbefab2f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f776f726b636f64652f7763726f757465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/workcode/wcrouter)[![Latest Version](https://camo.githubusercontent.com/ac71cff7337dd5beda84390fd90ca254b170c63d30f9ed12e84dd42b3452cab4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f64656e69736c756d65726b2f7763726f757465722e7376673f7374796c653d666c61742d737175617265)](https://github.com/denislumerk/wcrouter/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build](https://camo.githubusercontent.com/d737460a861c117a1dc945c057d99bdfbc15a2627a77b3e467dbb801010cec31/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f6275696c642f672f64656e69736c756d65726b2f7763726f757465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/denislumerk/wcrouter)[![Quality Score](https://camo.githubusercontent.com/244000021eed63fe48c44e473c41b5e1707e175359c74a1f9ad3ba08669ab8a9/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f64656e69736c756d65726b2f7763726f757465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/denislumerk/wcrouter)[![Total Downloads](https://camo.githubusercontent.com/ee9cb1d50efb7b46da988395408d3dd0f2aeaf191b6b351e43af8bde66250522/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f776f726b636f64652f7763726f757465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/workcode/wcrouter)

###### 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.

About WorkCode
--------------

[](#about-workcode)

###### WorkCode is a set of small and optimized PHP components for common tasks. Held by Denis Lumerk and the UpInside team. With them you perform routine tasks with fewer lines, writing less and doing much more.

[](#workcode-is-a-set-of-small-and-optimized-php-components-for-common-tasks-held-by-denis-lumerk-and-the-upinside-team-with-them-you-perform-routine-tasks-with-fewer-lines-writing-less-and-doing-much-more)

WorkCode é um conjunto de pequenos e otimizados componentes PHP para tarefas comuns. Mantido por Denis Lumerk e a equipe UpInside. Com eles você executa tarefas rotineiras com poucas linhas, escrevendo menos e fazendo muito mais.

### Highlights

[](#highlights)

- Router class with all RESTful verbs (Classe router com todos os verbos RESTful)
- Optimized dispatch with total decision control (Despacho otimizado com controle total de decisões)
- Requesting Spoofing for Local Verbalization (Falsificador (Spoofing) de requisição para verbalização local)
- It's very simple to create routes for your application or API (É muito simples criar rotas para sua aplicação ou API)
- Trigger and data carrier for the controller (Gatilho e transportador de dados para o controloador)
- Composer ready and PSR-2 compliant (Pronto para o composer e compatível com PSR-2)

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

[](#installation)

Router is available via Composer:

```
"workcode/wcrouter": "v1.0.*"
```

or run

```
composer require workcode/wcrouter
```

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. O exemplo abaixo mostra como:

#### apache

[](#apache)

```
RewriteEngine On
#Options All -Indexes

## ROUTER WWW Redirect.
#RewriteCond %{HTTP_HOST} !^www\. [NC]
#RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

## ROUTER HTTPS Redirect
#RewriteCond %{HTTP:X-Forwarded-Proto} !https
#RewriteCond %{HTTPS} off
#RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# 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;
  }
}

```

##### Routes

[](#routes)

```
