PHP code example of uzzal / legacy-router

1. Go to this page and download the library: Download uzzal/legacy-router 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/ */

    

uzzal / legacy-router example snippets


Route::controllers([
    'user'  => 'UserController',        
    'asset/report' => 'Asset\AssetReportController',
    'asset' => 'Asset\AssetController'        
]);

Route::controller('/user', 'UserController');


namespace App\Http;
...
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
use Uzzal\LegacyRouter\LegacyRouter;
...
class Kernel extends HttpKernel
{

    ...
    
    public function __construct(Application $app)
    {
        $router = new LegacyRouter($app['events'], $app);
        $app->singleton('router', function($app) use ($router){
            return $router;
        });
        parent::__construct($app, $router);
    }

    ...
}


namespace App\Console;
...
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Uzzal\LegacyRouter\LegacyRouter;
use Illuminate\Contracts\Foundation\Application;
...
class Kernel extends ConsoleKernel
{
    ...    
    public function __construct(Application $app)
    {
        $router = new LegacyRouter($app['events'], $app);
        $app->singleton('router', function($app) use ($router){
            return $router;
        });
        parent::__construct($app, $app['events']);
    }
    ...    
}

class TestController extends Controller
{

    public function getIndex(){
        return 'this is a get request';
    }

    public function postStore(){
        return 'this is a post request';
    }
}

Route::controller('/test', 'TestController');