aldaflux/standard-user-command-bundle
Installation:
composer require aldaflux/standard-user-command-bundle
Ensure your project uses Symfony 7.1+ (check composer.json under "require").
Enable the Bundle:
Add to config/bundles.php:
return [
// ...
Aldaflux\StandardUserCommandBundle\AldafluxStandardUserCommandBundle::class => ['all' => true],
];
First Use Case:
List existing users (requires a User entity with username/password fields):
./bin/console suc:user:list
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.
Integration with Symfony Security:
User entity extends Symfony\Component\Security\Core\User\UserInterface (or UserInterface + PasswordAuthenticatedUserInterface).// 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;
// ...
}
Customization:
CommandBus pattern).UserManager service (if needed) by binding your own implementation.Entity Mismatch:
User entity with username/password fields. Error: No such column: user.username → Verify your entity matches the expected schema.Password Hashing:
PasswordHasherInterface in your User entity’s setPassword():
public function setPassword(string $plainPassword): void
{
$this->password = $this->passwordHasher->hashPassword($this, $plainPassword);
}
Command Arguments:
add/change-password commands. Validate inputs manually or extend the command class.--dry-run flag (if supported) to preview changes before execution.APP_DEBUG=1) to see SQL queries and command execution flow.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');
}
// ...
}
Event Listeners:
Hook into user creation/modification via Symfony events (e.g., kernel.request or custom events).
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
How can I help you explore Laravel packages today?