About Vue project in a specific folder consuming Laravel data via Restfull API

Asked

Viewed 74 times

0

It is possible to / good practice to create a Vue project in a separate Laravel folder so that all authentication and data consumption is done via Laravel’s Restfull API?

/Raiz
    /Front <- Arquivos Vue
    /Back <- Arquivos Laravel

I have read in the Laravel documentation that within the Resources folder there is an example of implementation in Vue. But the fact is that I would like to use the Vue webpack template and all its features.

  • Hi Flávio, I think your question is out of scope N right answers for her... I would say "yes", the whole structure that organizes the files is good structure.

1 answer

2


Good afternoon!

It is possible yes.

In the Laravel Routes/api.php file you can define the routes and their respective functions.

Then just in your Vue project order those Urls you set to consume and manipulate the data.

To access the routes defined in the api.php file you need to add "api/" before the route name.

For example, if the following route has been defined:

Route::get('foo', function () {
    return 'Hello World';
}); 

The URL to access it would be: localhost/api/foo.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.