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 *:8080>
    DocumentRoot "C:/xampp/htdocs/ProjectPtsi/public"
    ServerName laravel.localhost
    ServerAlias www.laravel.localhost

    <Directory "C:/xampp/htdocs/ProjectPtsi">
    AllowOverride All
    Require all Granted
</VirtualHost>                  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']);


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 (, but if I have like a closure, for example:

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

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


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