PHP code example of marko / admin-auth
1. Go to this page and download the library: Download marko/admin-auth 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/ */
marko / admin-auth example snippets
use Marko\AdminAuth\Attributes\RequiresPermission;
use Marko\AdminAuth\Middleware\AdminAuthMiddleware;
use Marko\Routing\Attributes\Get;
use Marko\Routing\Attributes\Middleware;
class ProductController
{
#[Get('/admin/catalog/products')]
#[Middleware(AdminAuthMiddleware::class)]
#[RequiresPermission(permission: 'catalog.products.view')]
public function index(): Response
{
// Only admin users with 'catalog.products.view' permission
}
}