我怀疑这个问题可能与Stackoverflow的质量指导方针相冲突,您最好问两个独立的问题.即
- 在wep项目中何时/为什么学习/使用angular
- 如何设置文件夹 struct
For setting up the folder structure, check out these resources
http://scotch.io/tutorials/php/create-a-laravel-and-angular-single-page-comment-application
https://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.
因此,如果你想让你的网站/webapp获得这些好处,你需要用javascript编写这些功能.
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.