php 使用 Zend Framework 构建 REST API 服务器的示例?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5312762/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 20:57:39  来源:igfitidea点击:

Examples of building a REST API server using Zend Framework?

phpweb-serviceszend-frameworkzend-rest

提问by siliconpi

I'm new to Zend Framework (not to PHP), and I need to create a REST based API using Zend.

我是 Zend Framework 的新手(不是 PHP),我需要使用 Zend 创建一个基于 REST 的 API。

I've seen examples using Zend_Rest_Server, however other sources state that that has been deprecated.

我已经看到使用 Zend_Rest_Server 的示例,但是其他来源声明已弃用。

I'm unable to find a solid example which shows how I should be building such an API.

我找不到一个可靠的例子来说明我应该如何构建这样一个 API。

回答by wimvds

Zend_Rest_Server is indeed deprecated since ZF 1.9, you should use Zend_Rest_Controller instead. The following blog posts could be helpful : Building RESTful Services with Zend Frameworkand Create RESTful Applications Using The Zend Framework.

Zend_Rest_Server 确实从 ZF 1.9 开始被弃用,你应该使用 Zend_Rest_Controller 代替。下面的博客文章可能会有所帮助:构建RESTful服务与Zend框架创建使用Zend Framework的RESTful应用程序

回答by falko

May be this link would be helpful: Creating a PHP REST API Using the Zend Framework. This code example support REST data in the format of XML and JSON.

此链接可能会有所帮助:Creating a PHP REST API Using the Zend Framework。此代码示例支持 XML 和 JSON 格式的 REST 数据。

Prerequisites:

先决条件:

PHP version > 5
Zend Framework 1.9.2 (at the minimum)

回答by tasmaniski

If you want something a little more in details, you can check the book

如果你想要更详细的东西,你可以查看这本书

Zend Framework 2 Application Development.

Zend Framework 2 应用程序开发

The book explains construction of API oriented system in ZF2, through examples.

本书通过实例讲解了在ZF2中构建面向API的系统。

At the end of book you get:

在书的最后你会得到:

  • ZF2 API
  • ZF2 Client side app.
  • ZF2 API
  • ZF2 客户端应用程序。

The book has a lot of syntax errors as well as any book for programming, but it's only one on the market at this moment.

这本书和任何编程书籍一样有很多语法错误,但目前市场上只有它。