1. Go to this page and download the library: Download projecthanif/routescope library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
projecthanif / routescope example snippets
return [
// Only enable in local/development environments
'enabled' => env('ROUTESCOPE_ENABLED', app()->environment('local', 'development')),
// Customize the dashboard URL
'prefix' => env('ROUTESCOPE_PREFIX', 'routescope'),
// Hide routes you don't want to see (debug tools, internal routes, etc.)
'excluded_patterns' => [
'routescope',
'_ignition',
'sanctum/csrf-cookie',
'telescope',
'horizon',
],
];
use Projecthanif\RouteScope\Facades\RouteScope;
$routes = RouteScope::getAllRoutes();
// Returns:
[
'apiRoutes' => [...], // All /api/* routes
'webRoutes' => [...] // All other routes
]
use Projecthanif\RouteScope\Facades\RouteScope;
class InspectRoutes extends Command
{
public function handle()
{
$all = RouteScope::getAllRoutes();
$this->info('API Routes:');
foreach ($all['apiRoutes'] as $route) {
$this->line(" {$route['method']} {$route['path']}");
}
$this->info('Web Routes:');
foreach ($all['webRoutes'] as $route) {
$this->line(" {$route['method']} {$route['path']}");
}
}
}
use Projecthanif\RouteScope\Services\RouteScopeService;
class RouteAnalysisController extends Controller
{
public function __construct(
private RouteScopeService $routeScope
) {}
public function index()
{
$routes = $this->routeScope->getAllRoutes();
return view('admin.routes', compact('routes'));
}
}