work with laravel as backend and angular as fronte

2019-04-16 17:40发布

问题:

i am starting a project i want know that what is the best and most accepted way of using angular as front end and laravel as back end

can i do like in view folder of laravel i will install angular is it ok??

i tried to create api for that and in angluar i will call that api.

what is the most used way for doing this i have seen tutorials over this but most of the tuts are for angular version 2 and its outdated

so can you please tell me any way to work laravel 5.6 and angular 5 or 4 together

please give me your suggestion and thoughts

回答1:

So basiclly there are two ways you can do this.

One keep everything in one app, and do as you suggested and put in /view. Laravel has a php artisan preset react which sets the application up for React, but as far as i know there is not one for angular but sure you can find a tutorial on how to include Angular in your Laravel project.

The second way is keeping them seperated having a Laravel/Lumen app that provides there API, and a another project that has the Angular project running, than your Angular project will be calling the Laravel's api through two seperate servers running on Localhost example. I just answered another simillar questions of the benefits of doing it like this.

Read it here: https://stackoverflow.com/a/49181795/2783379



回答2:

I should stick with making an Laravel API and let your Angular app make calls to that API. This is the most common approach these days.



回答3:

You can view the documenation page of angular and laravel.

I think, this is the best way and it can help you to achieve your project using the two technology.

https://laravel-angular.io/

Installation:

composer require jadjoubran/laravel-angular

If you're using Laravel 5.5 or newer, you can skip this step. Inside your config/app.php, add the Service Provider:

Jadjoubran\LaravelAngular\Provider\LaravelServiceProvider::class

Then run the installation command:

php artisan laravelangular:install

Source: https://laravel-angular.io/docs/1/