Create new user without using the GUI

Hey all,

I am looking into ways to do test migrations and other types of testing, specifically using docker. I have been able to create the initial admin user and reset its password inside of the container, however, I do not know where to go at this point to create a new user.

My first option seems to be using the API. However, this requires an access token. I haven’t been able to find how to get an access token for the admin user from the CLI. Keep in mind that I can run any type
of PHP script as root if necessary, but I haven’t spent the time to try to dig into how PHP scripts can be run against Kanboard from the CLI.

My other option would be to access Kanboard directly from the CLI in order to run scripts against the running service, or modify the database directly. However, none of these are ideal, and I still don’t know how to run PHP scripts from the CLI. So, I have a couple of options here:

  1. Can I create a new user from the CLI/custom PHP script?
  2. Can I create and get an access token for the admin user from the CLI/custom PHP script?
  3. Is there another way that I haven’t thought of to create a user without using the WebGUI?

Thanks for your time.

– Andrew

Hey all,

I was able to hack together the following script. I was thinking of submitting a PR to get this command added, but I think it could probably be cleaned up a bit with error handling and such. Does anyone want to point out any low-hanging fruit that I could tackle before submitting a PR so that I don’t seem so low-effort on this?


namespace Kanboard\Console;

use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;
use Kanboard\Core\Security\Role;

class CreateUserAdminCommand extends BaseCommand
    protected function configure()
            ->setDescription('Create Admin User')
            ->addArgument('username', InputArgument::REQUIRED, 'Username')
            ->addArgument('password', InputArgument::REQUIRED, 'Password')
            ->addArgument('email', InputArgument::REQUIRED, 'Email')

    protected function execute(InputInterface $input, OutputInterface $output)
        $helper = $this->getHelper('question');
        $username = $input->getArgument('username');
        $password = $input->getArgument('password');
        $email = $input->getArgument('email');

        // Call the function to actually create the user
        $this->createUserAdmin($output, $username, $password, $email);

    private function createUserAdmin(OutputInterface $output, $username, $password, $email)
        $values = array(
                'username' => $username,
                'password' => $password,
                'email' => $password,
                'role' => Role::APP_ADMIN,
                'is_ldap_user' => 0
        $user_id = $this->userModel->create($values);
        if ($user_id !== false) {
            $output->writeln('<info>User Created Successfully</info>');
        } else {
            $output->writeln('<error>Unable to create your user.</error>');
            return false;

        return true;

Of course, I would want to add the corresponding changes a la

There was a lot of copy-paste from here:

Alternatively, if it would be preferable to have a more general-type “CreateUserCommand”, I could refactor for that, but this fixes my immediate use-case.