AngularJS和PHP后台 [英] AngularJS and PHP backend

查看:143
本文介绍了AngularJS和PHP后台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许它不是一个真正的问题,而这是一个的讨论的。我决定学的角度,用一个简单的任务,建立一个博客系统。我有几个问题。
免得想象PHP应用程序将有MVC结构,所以我有一些问题:

Maybe it's not a real question, rather is's a discussion. I decided to learn angular, using a simple task, build a blog system. And i have a few questions. Lest imagine that the php app will have the MVC structure, so i have some questions:


  • 我应该建立自己的后端仅作为RESTFUL的应用程序,并在角和PHP?
  • 使用JSON响应\\请求
  • 有关PHP应用程序的看法是什么,我应该用NG-INIT使用它们?

  • 路由,服务器端或客户端?

  • 什么缓存?

  • 而最后,但并非最不重要,我应该把逻辑有关数据的用户输入?

  • Should i build my back-end only as RESTFUL app, and use json response\request upon the angular and php?
  • What about the view in php app, i should use them with ng-init?
  • Routing, server side or client side?
  • What about caching?
  • And the last, but not the least, where i should put the logic about data that user will input?

有人可以给我的指示或指示,关于这个事情,也许有用链接的阅读文章,到PHP和角度结合起来,也许我做的错误的方式?

Can someone give me the instructions or directions, about this things, and maybe useful link's to read the articles, to combine the php and angular, or maybe i'm doing it in the wrong way?

推荐答案

您可能需要为实际考虑这种类型的应用程序的两个应用程序。

You might want to consider this type of application as actually TWO applications.

首先是后端,该API。您可以使用PHP框架来构建一个API,让你有数据持久性,验证(业务逻辑),等等,忘了前端现在,你只建立一个API,用于后端数据。

The first is the backend, the API. You can use your PHP framework to build an API that will allow you to have data persistency, validation (business logic), etc... and forget about the front end for now, you are only building an API for the backend data.

应用程序的第二部分是AngularJS前端。这包括所有的客户端看到的意见和一切。这些都不是从后端来了。

The second part of the app is the AngularJS frontend. This includes all of the views and everything that the client sees. None of that is coming from the backend.

这允许您使用后端API(PHP的位)作为数据存储,用它自己的验证的安全性,同时具有AngularJS无缝的用户体验和基本的客户端验证。

This allows you to use the backend API (the PHP bit) to act as the data store, with it's own validation for safety, while having the seamless user experience and basic client side validation from AngularJS.

路由是AngularJS,因为这是该客户端使用的实际前端。

Routing is AngularJS, as that is the actual frontend that the client is using.

缓存可以进行(如果需要的话)的后端,您的API。

Caching can be done (if needed) in the backend, your API.

验证将在前端和后端都发生,尽管它们可以是如果需要的话会略有不同。

Validation will happen in both the frontend and the backend, although they can be slightly different if need be.

记住,你严格建立后端作为一个API,而不考虑的前端(如是否会有它使用一个以上的应用程序),所以它有它自己的验证规则和逻辑。

Remember, you build the backend strictly as an API, without consideration for the frontend (as if there will be more than one app using it), so it will have it's own validation rules and logic.

希望有所帮助。

这篇关于AngularJS和PHP后台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆