NotFoundHttpException in RouteCollection.php line 161

2

Greetings, I'm working on laravel 5.3 and none of my routes work, the only one that works is the root path '/' , I do not understand why.

web.php

<?php
Route::get('/',function(){
    return view("certificado.index");
});
/*Route::get("certificado",function(){
    dd("Saludos");
});*/
Route::resource("certificado",'CertificadoGarantiaController');

When I enter the path http://localhost/baterias/public/certificado the only thing that shows me is the error:

  

NotFoundHttpException in RouteCollection.php line 161

And so with any other route that I believe.

I already try things like

  

php artisan cache: clear
    php artisan config: cache
    composer dump-autoload
    composer update

And nothing is still coming out the same error.

Edit route: list

Error

Path '/'

Index of CertificateGarantiaController

public function index()
{
    dd("hola");
}
    
asked by Shassain 23.09.2017 в 19:41
source

1 answer

1

After discussing in the chat, we were able to determine what was a routing confusion between Apache and Laravel:

  • According to the current configuration, Apache expected the path to be http://localhost/baterias/public/certificado .
  • Laravel expected the route not to include /public/ .

Considering that I have not worked Laravel with Apache (only with Nginx), I propose two solutions to this problem:

  • Create a VirtualHost in Apache for the project, as suggested in the following link:

    <VirtualHost laravel.dev:80>
      DocumentRoot "C:\xampp\htdocs\laravel\public"
      ServerAdmin laravel.dev 
      <Directory "C:\xampp\htdocs\laravel">
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
      </Directory>
    </VirtualHost>
    
  • Use Homestead (Vagrant) or Docker to fully virtualise the development environment and avoid inconveniences with the "local" machine.

answered by 24.09.2017 / 16:12
source