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

Attribute Execution Bundle Laravel Package

arnaud-23/attribute-execution-bundle

View on GitHub
Deep Wiki
Context7

AttributeExecutionBundle

CI PHPStan PHP Version Symfony Version License Code Coverage

Generic attribute execution system for Symfony.

Features

  • Attribute-based middleware pipeline
  • Built-in middleware for:
    • Security (role-based access control)
    • Cache (with configurable strategies)
    • Transaction management
  • Extensible architecture for custom middleware
  • High test coverage
  • Static analysis with PHPStan level 8
  • PSR-12 compliant code style

Installation

composer require arnaud-23/attribute-execution-bundle

Setup

The bundle will be automatically registered in your Symfony application. No additional configuration is required to start using the attributes.

Service Configuration

Services using the bundle's attributes are automatically configured with the attribute proxy. You don't need to add any additional tags or configuration.

# config/services.yaml
services:
    _defaults:
        autowire: true
        autoconfigure: true
        public: false

    # Your services will be automatically configured when using attributes
    App\Service\YourService: ~

Cache Configuration

If you're using the cache attribute, you can configure the cache strategies in your configuration:

# config/packages/attribute_execution.yaml
attribute_execution:
    cache:
        strategies:
            array: ~  # Uses Symfony's ArrayAdapter
            redis:    # Uses Redis
                dsn: 'redis://localhost:6379'
                options:
                    prefix: 'app_cache_'

Security Configuration

The security attribute requires the Symfony Security component to be installed:

composer require symfony/security-bundle

Usage

use Arnaud23\AttributeExecutionBundle\Attribute\Security;
use Arnaud23\AttributeExecutionBundle\Attribute\Cache;
use Arnaud23\AttributeExecutionBundle\Attribute\Transactional;

class YourService
{
    #[Security('ROLE_ADMIN')]
    #[Cache(strategy: 'redis', ttl: 3600)]
    #[Transactional('default')]
    public function yourMethod(): mixed
    {
        // Your code here
    }
}

Available Attributes

Security

#[Security('ROLE_ADMIN')]  // Method or class level

Cache

#[Cache]                    // Uses default strategy (array) with 300s TTL
#[Cache(strategy: 'custom')] // Uses custom strategy
#[Cache(ttl: 3600)]         // Custom TTL in seconds

Transaction

#[Transactional]            // Uses default connection
#[Transactional('custom')]  // Uses custom connection

Development

# Install dependencies
composer install

# Run tests
make test

# Run tests with coverage
make coverage

# Generate HTML coverage report
make coverage-html

# Run static analysis
make phpstan

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Security

If you discover any security-related issues, please email arnaud.h.lefevre@gmail.com instead of using the issue tracker. See our Security Policy for more details.

Changelog

See CHANGELOG.md for a list of changes.

License

This bundle is licensed under the MIT License. See the LICENSE file for details.

Credits

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.
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours