Why use AngularJs in frontend if Laravel is already used as backend? [closed] Why use AngularJs in frontend if Laravel is already used as backend? [closed] angularjs angularjs

Why use AngularJs in frontend if Laravel is already used as backend? [closed]


I suspect the question may conflict with stackoverflow's quality guidelines and you may almost be better asking two separate questions. i.e.

  1. When/Why learn/use angular in a wep project
  2. how to setup the folder structure

For setting up the folder structure, check out these resources

http://scotch.io/tutorials/php/create-a-laravel-and-angular-single-page-comment-applicationhttps://www.youtube.com/watch?v=hqAyiqUs93c

I can only really speak to why I use laravel with angularjs and you are right that you can use laravel without angular, but the reason I use angular as well as laravel is because there are some things that javascript is just better positioned for than server side apps e.g.

  • Using ajax and not having to reload the page whenever you want to check/process some small thing, like whether an email address a user types into a form is valid or not.
  • its faster because when you ajax back to the server, you dont have to load the entire page, just the pieces that are needed.
  • You can give immediate feedback to the user - e.g. when they are filling out a form - you can check that their input validates and give them feedback immediately.With lavavel you have to perform a round trip back to the server and possibly return a collection of error messages.

So if you want your website/webapp to have those benefits you need to write the functionality in javascript.I can't say I have used all the frameworks to then say that angular is the best one, but for me angular provides an integrated suite of solutions and to a wide range of issues, on top of an architecture that seems to work well.

I think this is partly why there are quite a few new concepts to learn and the need for these components is not immediately obvious.
This may be due to the fact that a component you are using to perform some function, e.g. using a $scope object to relay data between a controller and a view, also serves a function in the bigger picture, e.g. maintaining separation between the view and the controller - which helps with organising code, testability as well as other factors.

If you use angular as well as Laravel (as opposed to just Laravel by itself) you will then have the option of giving your users these benefits, because you have more options available e.g. use laravel where it best suits the requirements of your app and users or use angular where it gives the best result - and you will have a better web app in the end.


The big reason why i use laravel for backend and angularjs for frontend is that it make the app to be restful (both backend and frontend). The backend would only produce and consume data in json form making tasks like creating a mobile app version of the application an easier job mainly because of json.