PHP code example of aldrumo / route-loader

1. Go to this page and download the library: Download aldrumo/route-loader 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/ */

    

aldrumo / route-loader example snippets




namespace App\Routes;

use Aldrumo\RouteLoader\Contracts\RouteLoader;
use App\Models\Page;
use Illuminate\Support\Collection;

class FilledRouteLoader implements RouteLoader
{
    public function getRoutes(): Collection
    {
        return Page::where('is_active', true)->get();
    }
}


use Aldrumo\RouteLoader\Contracts\RouteLoader;
use App\Routes\PageRouteLoader;
$this->app->bind(
    RouteLoader::class,
    PageRouteLoader::class
);

use Aldrumo\RouteLoader\Generator;
use Illuminate\Support\Facades\Route;

Route::middleware('web')
    ->group(
        function () {
            $this->app[Generator::class]->generateRoutes();
        }
    );

resolve(\Aldrumo\RouteLoader\Generator::class)->clearRoutes();
bash
php artisan aldrumo:clear-routes