32 lines
750 B
PHP
32 lines
750 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Command;
|
|
|
|
use App\Service\RouteSyncService;
|
|
use Hyperf\Command\Annotation\Command;
|
|
use Hyperf\Command\Command as HyperfCommand;
|
|
use Psr\Container\ContainerInterface;
|
|
|
|
#[Command]
|
|
class RouteSyncCommand extends HyperfCommand
|
|
{
|
|
public function __construct(protected ContainerInterface $container)
|
|
{
|
|
parent::__construct('route:sync');
|
|
}
|
|
|
|
public function configure(): void
|
|
{
|
|
parent::configure();
|
|
$this->setDescription('同步 Hyperf 注解路由到 routes 表');
|
|
}
|
|
|
|
public function handle(): void
|
|
{
|
|
$result = $this->container->get(RouteSyncService::class)->sync();
|
|
$this->info("Synced {$result['synced']} routes to database.");
|
|
}
|
|
}
|