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

Acl Manager Laravel Package

sinarajabpour1998/acl-manager

View on GitHub
Deep Wiki
Context7
## Getting Started
Install the package via Composer:
```bash
composer require vendor/package-name

Publish the configuration (if applicable) and run migrations if needed. The package now includes log-manager as a dependency, so ensure your project’s composer.json aligns with its requirements. For first use, leverage the new log handler in controllers to streamline logging without manual setup:

use Vendor\PackageName\Logging\LogHandler;

class ExampleController extends Controller
{
    protected $logHandler;

    public function __construct(LogHandler $logHandler)
    {
        $this->logHandler = $logHandler;
    }

    public function exampleAction()
    {
        $this->logHandler->info("Action executed", ['context' => 'example']);
    }
}

Implementation Patterns

Dependency Injection

The package now integrates log-manager as a core dependency. Inject the LogHandler into controllers or services to centralize logging logic:

public function __construct(LogHandler $logHandler, LoggerInterface $logger)
{
    $this->logHandler = $logHandler;
    $this->logger     = $logger;
}

Use the LogHandler for structured logging (e.g., Laravel’s stack or Monolog) while falling back to the default logger if needed.

Middleware Integration

Extend existing middleware to include logging:

public function handle($request, Closure $next)
{
    $this->logHandler->debug("Request started", ['path' => $request->path()]);
    $response = $next($request);
    $this->logHandler->debug("Request completed", ['status' => $response->status()]);
    return $response;
}

Service Layer Logging

Wrap business logic in services and delegate logging to LogHandler:

class OrderService {
    public function __construct(private LogHandler $logHandler) {}

    public function createOrder(array $data)
    {
        $this->logHandler->info("Order creation initiated", $data);
        // ... business logic
    }
}

Gotchas and Tips

Dependency Conflicts

  • log-manager is now a required dependency. Ensure your project’s composer.json includes:
    "require": {
        "monolog/monolog": "^2.0",
        "vendor/package-name": "^1.3.6"
    }
    
    Run composer update to resolve conflicts if log-manager was previously optional.

LogHandler vs. LoggerInterface

  • The LogHandler extends Laravel’s LoggerInterface but adds convenience methods (e.g., context()). Prefer it over raw LoggerInterface for consistency:
    // Avoid (unless extending custom logic)
    $logger->info("Message", ['key' => 'value']);
    
    // Preferred
    $this->logHandler->info("Message", ['key' => 'value']);
    

Performance Considerations

  • Disable LogHandler in production for high-traffic endpoints by binding a null object in AppServiceProvider:
    $this->app->when(LogHandler::class)
        ->needs('$enabled')
        ->give(config('app.env') !== 'production');
    

Extending LogHandlers

  • Create custom handlers by extending LogHandler:
    class CustomLogHandler extends LogHandler {
        public function audit(string $message, array $context = [])
        {
            $this->stack->push(new AuditHandler(), 'audit');
            $this->info($message, $context);
        }
    }
    
    Register the custom handler in config/logging.php under the channels array.

Debugging

  • Use LogHandler::setLevel() to adjust logging verbosity dynamically:
    $this->logHandler->setLevel(\Monolog\Logger::DEBUG); // Override config
    
  • Check for LogHandler binding errors in AppServiceProvider@register() if DI fails.

NO_UPDATE_NEEDED would **not** apply here due to the new features/dependencies introduced.
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