Skip to content

Commit 88657fa

Browse files
committed
suppot command
1 parent 63b2b91 commit 88657fa

File tree

4 files changed

+59
-2
lines changed

4 files changed

+59
-2
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Command;
6+
7+
use Symfony\Component\Console\Command\Command;
8+
use Symfony\Component\Console\Input\InputInterface;
9+
use Symfony\Component\Console\Output\OutputInterface;
10+
11+
class GetRoadRunnerCommand extends Command
12+
{
13+
protected function execute(InputInterface $input, OutputInterface $output): int
14+
{
15+
$command = "curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/roadrunner-server/roadrunner/master/download-latest.sh | sh && tar -xzvf roadrunner-*.tar.gz && rm -rf roadrunner-*.tar.gz && mv roadrunner-*/rr . && rm -rf roadrunner-* && chmod +x ./rr";
16+
$result = shell_exec($command);
17+
$output->writeln($result);
18+
19+
return Command::SUCCESS;
20+
}
21+
22+
protected function configure(): void
23+
{
24+
$this->setName('roadrunner:get')
25+
->setDescription('get last version of roadrunner');
26+
}
27+
}

bin/console

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
declare(strict_types=1);
5+
6+
use Symfony\Component\Console\Application;
7+
8+
require __DIR__.'/../vendor/autoload.php';
9+
10+
date_default_timezone_set('Asia/Shanghai');
11+
12+
$application = new Application();
13+
14+
$commands = require __DIR__.'/../config/commands.php';
15+
16+
$application->addCommands(array_map(static function (string $command) {
17+
return new $command();
18+
}, $commands));
19+
20+
/** @noinspection PhpUnhandledExceptionInspection */
21+
$application->run();

index.php renamed to bin/index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
use MicroPHP\Framework\Application;
66

7-
require __DIR__.'/vendor/autoload.php';
7+
require __DIR__.'/../vendor/autoload.php';
88

99
date_default_timezone_set('Asia/Shanghai');
1010

11-
! defined('BASE_PATH') && define('BASE_PATH', __DIR__);
11+
! defined('BASE_PATH') && define('BASE_PATH', __DIR__ . '/../');
1212

1313
/** @noinspection PhpUnhandledExceptionInspection */
1414
Application::boot();

config/commands.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use App\Command\GetRoadRunnerCommand;
6+
7+
return [
8+
GetRoadRunnerCommand::class,
9+
];

0 commit comments

Comments
 (0)