Route of api in Laravel 5.4

0

Through the composer, I started a project with the command:

composer create-project --prefer-dist laravel/laravel api

After the installation of the dependencies, I was able to see the "welcome" of the application (through the default wheel that is already created at project start time).

In the wheel file, within the route directory the web.php file exists the code:

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

So far so good, even though the application was created correctly, but I'm not interested in doing the web application for laravel, I just want to use the laravel of api, for that:

Inside the route directory in the api.php file:

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

Should be the routes for access to api, however regardless of the route I configure in this file (api.php) is not processed by the application, the following error is displayed when I access the http://localhost/api/public/api link:

What can I have done wrong, why can not I access the api routes?

    
asked by anonymous 21.05.2018 / 04:16

1 answer

0

Open the terminal (mac) or cmd (windows) prompt, navigate to the project folder and enter the following.

php artisan route:list

The laravel the URI of the existing routes.

Watch out for the RouteServiceProvider. The API routes have a 'api' prefix. From the way you are calling I think you should have put the tooth project in a folder called api.

    
22.05.2018 / 14:46