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

Standard User Command Bundle Laravel Package

aldaflux/standard-user-command-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Installation:

    composer require aldaflux/standard-user-command-bundle
    

    Ensure your project uses Symfony 7.1+ (check composer.json under "require").

  2. Enable the Bundle: Add to config/bundles.php:

    return [
        // ...
        Aldaflux\StandardUserCommandBundle\AldafluxStandardUserCommandBundle::class => ['all' => true],
    ];
    
  3. First Use Case: List existing users (requires a User entity with username/password fields):

    ./bin/console suc:user:list
    

Implementation Patterns

Core Workflows

  1. User Management:

    • Add Users:

      ./bin/console suc:user:add username email password --roles=ROLE_USER
      

      Tip: Use --roles for bulk role assignment (e.g., ROLE_ADMIN,ROLE_USER).

    • Password Updates:

      ./bin/console suc:user:change-password username new_password
      

      Partial args: Omit username to prompt interactively.

  2. Integration with Symfony Security:

    • Ensure your User entity extends Symfony\Component\Security\Core\User\UserInterface (or UserInterface + PasswordAuthenticatedUserInterface).
    • Example entity:
      // src/Entity/User.php
      namespace App\Entity;
      use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
      use Doctrine\ORM\Mapping as ORM;
      
      #[ORM\Entity]
      class User implements PasswordAuthenticatedUserInterface
      {
          #[ORM\Column]
          private string $username;
          #[ORM\Column]
          private string $password;
          // ...
      }
      
  3. Customization:

    • Override commands via command decorators (Symfony’s CommandBus pattern).
    • Extend the bundle’s UserManager service (if needed) by binding your own implementation.

Gotchas and Tips

Pitfalls

  1. Entity Mismatch:

    • The bundle assumes a User entity with username/password fields. Error: No such column: user.username → Verify your entity matches the expected schema.
  2. Password Hashing:

    • The bundle does not auto-hash passwords. Use Symfony’s PasswordHasherInterface in your User entity’s setPassword():
      public function setPassword(string $plainPassword): void
      {
          $this->password = $this->passwordHasher->hashPassword($this, $plainPassword);
      }
      
  3. Command Arguments:

    • No validation for add/change-password commands. Validate inputs manually or extend the command class.

Debugging Tips

  • Dry Runs: Use --dry-run flag (if supported) to preview changes before execution.
  • Logging: Enable debug mode (APP_DEBUG=1) to see SQL queries and command execution flow.

Extension Points

  1. Custom Fields: Add fields to the add command by extending the AddUserCommand class:

    // src/Command/CustomAddUserCommand.php
    namespace App\Command;
    use Symfony\Component\Console\Command\Command;
    use Symfony\Component\Console\Input\InputArgument;
    use Symfony\Component\Console\Input\InputInterface;
    use Symfony\Component\Console\Output\OutputInterface;
    
    class CustomAddUserCommand extends Command
    {
        protected function configure(): void
        {
            $this->addArgument('custom_field', InputArgument::OPTIONAL, 'Custom user field');
        }
        // ...
    }
    
  2. Event Listeners: Hook into user creation/modification via Symfony events (e.g., kernel.request or custom events).

  3. Configuration: Override bundle defaults in config/packages/aldaflux_standard_user_command.yaml:

    aldaflux_standard_user_command:
        default_roles: [ROLE_USER]
        password_hasher: 'app.password_hasher' # Custom hasher service
    
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.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui