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 Aware Command Bundle Laravel Package

bentools/user-aware-command-bundle

View on GitHub
Deep Wiki
Context7

UserAwareCommandBundle

This Symfony bundle provides a user value to Doctrine Entities that implements Gedmo Blameable when using Console commands.

Installation

composer require bentools/user-aware-command-bundle

Then, enable the bundle into Symfony's AppKernel.php:

# app/AppKernel.php
class AppKernel extends Kernel
{
    public function registerBundles() 
    {
        // ...
        $bundles[] = new BenTools\UserAwareCommandBundle\UserAwareCommandBundle();
    }
}

Usage

The bundle just works out of the box, provided you already have the Blameable extension configured and working on your entities. Your console command just has to implement BenTools\UserAwareCommandBundle\Model\UserAwareInterface, which contains no method:

namespace AppBundle\Command;

use BenTools\UserAwareCommandBundle\Model\UserAwareInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class DoMyCommand extends Command implements UserAwareInterface 
{
    protected function execute(InputInterface $input, OutputInterface $output) {
	    // ...
	}
}

By default, the bundle will bind the System user to your createdBy / updatedBy properties.

You can change this user per command run with the --user option:

php bin/console do:mycommand --user Ben

Advanced configuration

# app/config.yml

user_aware_command:
    user_name: System # change default user
    option_name: user # change default command option
    option_shortcut: u # set option shortcut
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.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware