1. Go to this page and download the library: Download 89bsilva/my-route library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
89bsilva / my-route example snippets
$routes = new MyRoute();
#Método Utilizado para criar uma rota que responde a todos os tipos de requisições
all(string $url, string $pageFilePath)
#Método Utilizado para criar uma rota que responde a requisições do tipo GET
get(string $url, string $pageFilePath)
#Método Utilizado para criar uma rota que responde a requisições do tipo POST
post(string $url, string $pageFilePath)
#Método Utilizado para criar uma rota que responde a requisições do tipo PUT
put(string $url, string $pageFilePath)
#Método Utilizado para criar uma rota que responde a requisições do tipo DELETE
delete(string $url, string $pageFilePath)
#Método Utilizado para criar uma rota que responde a requisições do tipo OPTIONS
options(string $url, string $pageFilePath)
#Método Utilizado para criar uma rota que responde a requisições dos tipos passados em $to
to(array $to, string $url, string $pageFilePath)
#Método Utilizado para proteger uma rota já criada com uma das chamadas acima
guard(string $route, string $filePath)
#Será criado a váriavel $id e estará disponível para o arquivo api.php
$routes->get('/api/user/:id', 'api.php');
#Será chamado o método read de Api e passado $id como argumento da chamada. Api->read($id)
$routes->get('/api-class/user/:id', 'api-class.php:Api=read');
/**
* Se foi solicitado a rota: /a/b/c/d e não houver nenhuma configuração de rota anterior a rota abaixo
* o MyRoute irá chamar o método noExist da Classe NotFound e passará o seguinte array como argumento. array('a','b','c','d')
*/
$routes->all('/?', '404.php:NotFound=noExist');
#Criando a rota
$route->get('[gPDF]/agenda/:data/gerar-pdf', 'site.php:MeuSite=agenda');
#Criando um guarda para a rota
$route->guard('gPDF', 'guardas.php:GuardasDeRotas=gerarPDF');
$routes->activate();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.