Skip to content

Instantly share code, notes, and snippets.

@dracony
Created July 19, 2019 06:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dracony/9f4a36c5d6f7179f477714587b3f4061 to your computer and use it in GitHub Desktop.
Save dracony/9f4a36c5d6f7179f477714587b3f4061 to your computer and use it in GitHub Desktop.
<?php
require __DIR__.'/vendor/autoload.php';
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use GuzzleHttp\Client;
$application = new Application();
class RegisterUserCommand extends Command
{
protected static $defaultName = 'register';
private $client;
public function __construct() {
$this->client = new Client([
'base_uri' => 'http://127.0.0.1'
]);
parent::__construct();
}
protected function configure()
{
$this->setDescription('Registers a user.');
$this->addArgument('username', InputArgument::REQUIRED);
$this->addArgument('publicKey', InputArgument::REQUIRED);
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->client->post('/register', [
'json' => [
'username' => $input->getArgument('username'),
'publicKey' => file_get_contents($input->getArgument('publicKey'))
]
]);
}
}
$application->add(new RegisterUserCommand());
$application->run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment