Routes problem with controllers

Posted 2 years ago by AdrianoMaia

So, I'm using Laravel 5.4 and xampp.

I create a virtual host in xampp with the following code and url:


<VirtualHost *:8080>
    DocumentRoot "C:/xampp/htdocs"
    ServerName localhost
</VirtualHost>

<VirtualHost *:8080>
    DocumentRoot "C:/xampp/htdocs/ProjectPtsi/public"
    ServerName laravel.localhost
    ServerAlias www.laravel.localhost

    <Directory "C:/xampp/htdocs/ProjectPtsi">
    AllowOverride All
    Require all Granted
    </Directory>
</VirtualHost>


127.0.0.1                  laravel.localhost

I have the following code in web.php (routes file):


Route::get('/', ['uses' => '[email protected]', 'as' => 'index']);

Route::get('about', ['uses' => '[email protected]', 'as' => 'about']);

Route::get('/home', ['uses' => '[email protected]', 'as' => 'home']);

Auth::routes();

And in the HomeController.php:

public function index()
    {
        return view('welcome');
    }
    public function about()
    {
        return view('about');
    }
    public function home()
    {
        return view('home');
    }

the problem is, if I have the routes pointed to the controller file (like I show before) doesn't work (http://i.imgur.com/6AxhglL.png), but if I have like a closure, for example:


Route::get('/', function () {
    return view('welcom');
});

the program works, and I don't know why.

Thanks

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.