I know that AngularJs is FrontEnd and Laravel is Backend but my questions is:

为什么我首先需要使用AngularJs,因为我需要的一切都是通过Laravel完成的?

From what I understood is that I can make an app with either langs JS or PHP, but I find lots of users use both which for me as a beginner it seems like an overkill, so could someone please explain in the simplest possible form of an answer.

What is the benefit of using both in the same project ? And how do you usually structure your app/folders when you use both specially that both are MVC ?

推荐答案

我怀疑这个问题可能与Stackoverflow的质量指导方针相冲突,您最好问两个独立的问题.即

  1. 在wep项目中何时/为什么学习/使用angular
  2. 如何设置文件夹 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.

Laravel相关问答推荐

Laravel Livewire与自定义JS有关的多姆问题

Laravel 5 Eloquent 范围连接并 Select 特定列

通过单击按钮保存 PhpSpreadSheet

Laravel 5.4 LengthAwarePaginator

Laravel 扩展验证自定义消息

localhost 和stream_socket_enable_crypto():SSL 操作失败,代码为 1

Laravel 监听器监听多个事件

合并和排序两个 Eloquent 集合?

找不到列:1054字段列表中的未知列0-Laravel-我的代码中的任何地方都没有0列

在 Laravel 中下载后如何重定向?

Laravel 5.1 重命名项目

在 laravel 6.0 中未定义命令ui

如何重定向到laravel上的公共文件夹

Laravel Mail 发送Electron邮件但返回 false

Blade 中的条件扩展

Laravel 验证:数字和整数之间的区别?

在 laravel 中安装 vue 3.0

Laravel 4:分析器在哪里?

Laravel 如何在 Eloquent 模型中添加自定义函数?

你如何在 Laravel 5.3 的新通知服务生成的Electron邮件中添加图像?