nasution/laravel-implicit-routes

Laravel implicit routes, very similar like CodeIgniter.

v0.1.0 2016-08-05 18:30 UTC

This package is auto-updated.

Last update: 2024-12-10 10:50:00 UTC


README

Make implicit routes to Laravel. It's very similar like CodeIgniter routes.

Installation

composer require nasution/laravel-implicit-routes

Register service provider inside providers in config/app.php file.

Nasution\ImplicitRoutes\ServiceProvider::class,

Usage

Add Route::anything() to your routes file.

Route::anything();

Route::get('/', 'HomeController@welcome');

Now, you have capability to visit any path. For example, if you visit http://localhost/products/shoes/42, it's equivalent

Route::any('products/shoes/{param0}', 'ProductsController@shoes');

class ProductsContoller extends Controller
{
    public function shoes($id)
    {
        return $id; // 42
    }
}

If you visit address without second segment, it will use index method. For example http://localhost/products, it's equivalent

Route::any('products', 'ProductsController@index');

class ProductsContoller extends Controller
{
    public function index()
    {
        //
    }
}

License

MIT © Mulia Arifandi Nasution