0

I want to build a project with 2 separated repositories, for front-end and back-end. As a front end framework I want to use Angular 2+ and as a back end framework Laravel. I do not want to use Laravel's views. Can I somehow expose Angular's dist (build) in Laravel's project? If yes, where do I need to place dist folder (resources, public, elsewhere..)? What do I have to do with routes/web.php file?

I know for a fact that you can do this in Java projects because this is what we are doing at work so there must be a (non-hacky) way.

  • 1
    When you build an angular project, a dist folder will be created, which may be served through a static web server, which basically means having this dist folder available on your server and having code to serve its contents statically. I don't know php or laravel, but it should be easy to setup a static web server using it. In this case, you would have your views rendered on the browser. If you would like to render your (angular) views on server side you may use [angular universal](https://angular.io/guide/universal), but AFAIK, it is only available for node (javascript) servers so far. – GCSDC Dec 21 '18 at 23:22

2 Answers2

2

Can I somehow expose Angular's dist (build) in Laravel's project?

You can but I would recommend that you do not.

What do I have to do with routes/web.php file?

You can delete it if all you are exposing is an API that is consumed by a front-end application.

The two projects should not commingle. Keep each code base in a separate repository and only communicate with the API via HTTP calls from your Angular app.

Ben Harold
  • 6,242
  • 6
  • 47
  • 71
  • Why do you not suggest it? Are there any security issues? If I wanted to do it anyway, how should I do it? – user2952585 Dec 22 '18 at 13:14
  • AngularJS is used to create single page web applications which take over the browser's routing mechanism via the history API. This directly conflicts with how a typical Laravel application handles routing, and causes all kinds of headaches that can be avoided by keeping the projects separate. – Ben Harold Dec 31 '18 at 23:49
0

Why don't you try with separate angular for the front end and separate back end in laravel.

Before a couple of months,

I have started working on a project with technologies Angular 5 on the front end and Laravel for the back end.

As far as I know, integrating angular 2+ in any another framework is somewhat difficult except node js.

Angular is having its own way of development and same for laravel.

I would suggest you purchase the separate instance for each. Keep angular on separate and laravel on separate. I am not aware of whether you have used this strategy before or not but you go by creating a rest service in laravel and use those in angular.

In this way, you can create a view in angular and back-end in laravel and play by using rest services.

To know more details about angular 2+ deployment on server, you can visit click here

Raj
  • 598
  • 5
  • 23