0

I'm learning Laravel ad routes not working i don;t know why .. there is three files ( Welcome.blade.php & route.php & tryaction.php ) , tryaction is a controller

in Welcome.balde.php :

<ul>
    <li><a href="{{ route('benice', ['action' => 'hug']) }}">Hug</a></li>
    <li><a href="{{ route('benice', ['action' => 'kiss']) }}">Kiss</a></li>
    <li><a href="{{ route('benice', ['action' => 'slap']) }}">Slap</a></li>
</ul>

in route.php :

Route::get('/{action}/{name?}', [
    'uses' => 'tryaction@doget',
    'as' => 'benice'
]);

in tryaction.php :

public function doget($action, $name = null){
    return view('actions.'.$action,['name'=>$name]);
}

why it's not working and gives me notFound exception ?

note:actions views ar located in a folder called actions inside views

Now I tried something but still don't know the problem

I created the app using composer inside a folder inside htdocs using xampp server, the hierarchy looks like:

├── htdocs
│   ├── laravelprojects
│   |   ├── myapp

when I moved myapp to htdocs directly it works .. why is that ?

Poula Adel
  • 609
  • 1
  • 10
  • 33

2 Answers2

1

In versions of Laravel < 5.3:

All routes live within the app/Http/routes.php


You need to make sure you are referencing the right file.

  • Navigate to app/Providers/RouteServiceProvider
  • Confirm that the appropriate file is being required.

    public function map(Router $router)
    {
        $router->group(['namespace' => $this->namespace], function ($router) {
            require app_path('Http/routes.php');
        });
    }
    
Afshan Shujat
  • 541
  • 4
  • 9
-2

You should read this:

HTTP Routing - Laravel Docs

Ketav
  • 760
  • 1
  • 8
  • 27