Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

User Permission Bundle Laravel Package

effinix/user-permission-bundle

View on GitHub
Deep Wiki
Context7

Easily protect routes with unique permissions

With one easy attribute, you can now protect controller methods and invokable controllers e.g:

src/Controller/Controller.php
<?php declare(strict_types=1);

namespace App\Controller;

use Effinix\UserPermissionBundle\Attribute\Attribute\Routing\RequirePermission;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Component\Routing\Attribute\Route;

#[AsController]
class Controller
{
    #[Route(
        name: 'public_website',
    )]
    #[RequirePermission('login')]
    public function index()
    {
        return new Response("Hello world!");
    }
}

Implement UserInterface to provide access to these routes

src/Entity/User.php
<?php declare(strict_types=1);

namespace App\Entity;

use Effinix\UserPermissionBundle\DependencyInversion\UserInterface;

class User implements UserInterface
{
    ...
    public function hasPermission(string $permission) : bool {
        // check if the permission is valid for this user
        return in_array($permission, $this->getPermissions());
    }
    
    /**
     * @return string[]
     */
    public function getPermissions() : array {
        // domain logic way of getting user permissions (e.g. storing in the database)
        return ['login'];
    }
}

Default config file:

effinix_user_permission:
  permission_store:
    provider:
    permissions:
      - login
  do_cache: true

when@dev:
  effinix_user_permission:
    do_cache: false
    logger: app.my-logger
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
aashan/pimcore-mcp-bundle
solution-forest/ai-kit-core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin