AIPD TECH AIPD TECH - 8 months ago 68
PHP Question

Laravel 5.2 routing like cakephp

I am new to laravel. I am coming form cakephp, so routing is creating a bit of difficulty for me.

I have tried the Question but getting error in that.
I also tried for

but not getting the the result i want.

I simply want the rounting to be

also, if i can get answer for the backend management like


In Laravel 5.2 the use of Route::controller('Controller') has been deprecated due to annoying race conditions.

To get your desired result. Let's say you have a controller App\Http\Controllers\MyController.

In your routes.php file you would have the following:

Route::group(['middleware' => ['web']], function(Router $router) {

    // Note the question marks after the parameters
    // this makes them optional.
    $router->get('uri/{action?}/{param1?}/{param2?}', [
        'uses' => 'MyController@getIndex'

You would now have a controller method getIndex

// As the parameters were optional, make sure to give them
// default values.
public function getIndex($action = null, $param1 = null, $param2 = null)
    // Your route logic