PHP code example of yiiboot / routing

1. Go to this page and download the library: Download yiiboot/routing 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/ */

    

yiiboot / routing example snippets


return [
    // ...
    'yiiboot/attributed' => [
        'paths' => [
            dirname(__DIR__) . '/src/Controller'
        ]
    ]
];

namespace App\Controller;

use Yiiboot\Routing\Attribute\Route;use Yiisoft\Router\CurrentRoute;

#[Route('/customs', name:'customs.', middleware: [
    FormatDataResponseAsJson::class
])]
final class CustomController
{
    #[Route('/{page:\d+}', name: 'list', method: 'GET', defaults: ['page' => 1])]
    public function list(): ResponseInterface
    {
        // ...
    }

    #[Route('/{id:\d+}', name: 'view', method: 'GET')]
    public function view(CurrentRoute $route): ResponseInterface
    {
        $id = $route->getArgument('id');
        // ...
    }

    #[Route(name: 'create', method: 'POST')]
    public function create(): ResponseInterface
    {
        // ...
    }

    #[Route('/{id:\d+}', name: 'delete', method: 'DELETE')]
    public function delete(CurrentRoute $route): ResponseInterface
    {
        $id = $route->getArgument('id');
        // ...
    }
}