1. Go to this page and download the library: Download casdorio/annotation-router 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/ */
casdorio / annotation-router example snippets
/**
* @Controller(path:"api/v1", options:['filter' => 'roles:user,admin'])
*/
class MyController extends BaseController
{
/**
* @Route(method:"GET", path:"items", options:['filter' => 'roles:user,admin'])
*/
public function getItems()
{
// Lógica para retornar itens
}
/**
* @Route(method:"POST", path:"items", options:['filter' => 'roles:user,admin'])
*/
public function createItem()
{
// Lógica para criar um item
}
}
#[Controller(path: 'api/v2', options: ['filters' => 'roles:user,admin'])]
class MyController extends BaseController
{
#[Route(method: 'GET', path: 'items', options: ['filters' =>'roles:user,admin'])]
public function getItems()
{
// Lógica para retornar itens
}
#[Route(method: 'POST', path: 'items', options: ['filters' => 'roles:user,admin'])]
public function createItem()
{
// Lógica para criar um item
}
}
#[Controller]
class SimpleController extends BaseController
{
#[Route(method: 'GET', path: 'status')]
public function status()
{
return 'OK';
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.