uzzal/legacy-router is a Laravel package for legacy router for laravel framework 5.2+.
It currently has 0 GitHub stars and 1.374 downloads on Packagist (latest version v1.0.3).
Install it with composer require uzzal/legacy-router.
Discover more Laravel packages by uzzal
or browse all Laravel packages to compare alternatives.
Last updated
Laravel router has been deprecated some features, like Route::controller,
and Route::controllers. If your code looks something like the code below then chances are
they are no longer supported by the latest versions of the Laravel. To be more precise
these feature has been deprecated since laravel 5.2.
This library brings back those legacy route features.
Route::controllers([
'user' => 'UserController',
'asset/report' => 'Asset\AssetReportController',
'asset' => 'Asset\AssetController'
]);
or
Route::controller('/user', 'UserController');
composer require uzzal/legacy-router
In your laravel app/Http/Kernel.php add/edit your constructor like that code given below
<?php
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);
}
...
}
In your laravel app/Console/Kernel.php add/edit your constructor like the code given below
make sure you import the
<?php
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']);
}
...
}
That's it. You're done!
If you are one of those rare people who don't know how this router worked this part is for you.
Imagine you have a controller in your app/Http/Controllers directory like this
class TestController extends Controller
{
public function getIndex(){
return 'this is a get request';
}
public function postStore(){
return 'this is a post request';
}
}
then you can call it using the legacy router like this
Route::controller('/test', 'TestController');
This will automatically mapped with your controller. For more on this take a look at this link implicit-controllers