Search code examples
phpsymfonylaravellaravel-4url-routing

Getting NotFoundException in Laravel 4


I am new to Laravel 4. I am trying here is that whenever I click in a link I will go to route, there I will print something. Now one part of the link has to be variable. In the route I want to print the variable.

The code for the link is given below:

URL::to("category/{$category}

This code in routes.php is

Route::get('category/{$c}', function($c){
    return $c;
});

It is showing me:

Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException.


Solution

  • Try this ({c} instead of {$c})

    Route::get('category/{c}', function($c){
        echo $c;
    });