1. Go to this page and download the library: Download gregs/attribute-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/ */
gregs / attribute-router example snippets
use Gregs\AttributeRouter\AttributeRouter;
AttributeRouter::namespace('App\Http\Your\Namespace');
namespace App\Http\Your\Namespace;
use Gregs\AttributeRouter\Attributes\Controller;
use Gregs\AttributeRouter\Attributes\Get;
#[Controller]
class YourController
{
#[Get('uri')]
public function index()
{
return;
}
}
namespace App\Http\Your\Namespace;
use Gregs\AttributeRouter\Attributes\Controller;
use Gregs\AttributeRouter\Attributes\Get;
use Gregs\AttributeRouter\Attributes\Post;
use Gregs\AttributeRouter\Attributes\Patch;
use Gregs\AttributeRouter\Attributes\Prefix;
use Gregs\AttributeRouter\Attributes\Middleware;
#[Controller]
#[Prefix('v1')]
class YourController
{
#[Get('uri')]
#[Prefix('entity')]
public function index()
{
return;
}
#[Post('uri')]
#[Prefix('entity')]
#[Middleware('auth-sanctum')]
public function post()
{
return;
}
#[Patch('uri')]
#[Prefix('entity')]
#[Middleware('auth-sanctum')]
public function patch()
{
return;
}
}