The AropixelAdminBundle provides a command to quickly create a new administrative user for your application. This user is automatically assigned the ROLE_SUPER_ADMIN role.
To create a new admin user, run the following command:
php bin/console aropixel:admin:create-userThe command can be run in interactive mode or by providing options.
If you run the command without options, it will ask you for:
- Email: The email address of the new administrator.
- First Name: The administrator's first name.
- Last Name: The administrator's last name.
You can also provide the information directly via command-line options:
php bin/console aropixel:admin:create-user --login=admin@example.com --first_name=John --last_name=Doe --password=secretAvailable options:
--login: The user's email address.--first_name: The user's first name.--last_name: The user's last name.--password: (Optional) The user's password.
Warning
By default, if the login is admin, the password defaults to admin.
Never use the default admin/admin credentials in a production environment.
When running the command in non-interactive mode (e.g., in a CI/CD pipeline or setup script with --no-interaction), you must provide the required options (--login, --first_name, --last_name, --password).
Special case for Development:
In the dev environment (where APP_ENV=dev), you can run the command without any options in non-interactive mode to create a default admin/admin account:
# Works only in dev environment
php bin/console aropixel:admin:create-user --no-interactionIn any other environment (e.g., prod), the command will fail if you try to use the default admin/admin credentials in non-interactive mode, as a security measure.
- If the login provided is not "admin", the command will attempt to send an activation email to the user so they can set their own password and activate their account.
- If the login is "admin", the account is automatically enabled and initialized.
- If you don't provide a password via the
--passwordoption and the login is "admin", the default password will be "admin". - If you provide a login other than "admin" and don't provide a password, the user will need to set it via the activation email.
The command validates the email format and ensures that required fields (First Name, Last Name) are not empty. It also checks if a user with the same email already exists in the database.