mirror of
https://gh.wpcy.net/https://github.com/fairpm/aspirecloud.git
synced 2026-06-20 02:22:28 +08:00
28 lines
779 B
PHP
28 lines
779 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Support\Facades\Request;
|
|
use Illuminate\Support\Facades\Route;
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|
|
|
class RouteTestCommand extends Command
|
|
{
|
|
protected $signature = 'route:test {uri}';
|
|
protected $description = 'Match path against routes';
|
|
|
|
public function handle(): int
|
|
{
|
|
$uri = $this->argument('uri');
|
|
$router = Route::getRoutes();
|
|
$request = Request::create($uri);
|
|
try {
|
|
$route = $router->match($request);
|
|
$this->info("MATCH: {$route->uri} [{$route->getName()}]");
|
|
} catch (NotFoundHttpException) {
|
|
$this->fail("Route not found for $uri");
|
|
}
|
|
return 0;
|
|
}
|
|
}
|