PHP code example of sirix / mezzio-routing-contracts
1. Go to this page and download the library: Download sirix/mezzio-routing-contracts 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/ */
sirix / mezzio-routing-contracts example snippets
use Attribute;
use Sirix\Mezzio\Routing\Contracts\RouteAttributeModifierInterface;
#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
final readonly class RequireTenant implements RouteAttributeModifierInterface
{
public function __construct(private string $tenantHeader = 'x-tenant-id') {}
public function getMiddleware(): array
{
return [RequireTenantMiddleware::class];
}
public function getDefaults(): array
{
return ['tenant_header' => $this->tenantHeader];
}
}
use Sirix\Mezzio\Routing\Attributes\Attribute\Get;
final class OrdersHandler
{
#[Get('/orders', name: 'orders.list')]
#[RequireTenant('x-org-id')]
public function list(): ResponseInterface
{
// ...
}
}
interface RouteAttributeModifierInterface
{
/** @return list<class-string<MiddlewareInterface>|non-empty-string> */
public function getMiddleware(): array;
/** @return array<string, mixed> */
public function getDefaults(): array;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.