简体   繁体   English

在Symfony2应用程序之外使用RESTful API包“ FOSRestBundle”

[英]Using the RESTful API package “FOSRestBundle” outside of a Symfony2 application

I'm supporting a legacy ZF1 application which now needs to expose a RESTful API to the outside world. 我正在支持旧版ZF1应用程序,该应用程序现在需要向外界公开RESTful API。 I'd like to take advantage of a modern PHP package for some of the API's boilerplate functionality (authentication, request parsing, response generation in multiple data formats, etc.) rather than coding it all from scratch, or using ZF1's poorly-documented REST library. 我想利用现代PHP包来实现API的某些样板功能(身份验证,请求解析,以多种数据格式生成响应等),而不是从头开始对其进行编码,或者使用ZF1的文献记载不多的REST图书馆。

Packagist suggests that FOSRestBundle is the most popular PHP component for developing RESTful API servers. Packagist建议FOSRestBundle是用于开发RESTful API服务器的最受欢迎的PHP组件。 And as far as I understand it, Symfony2 components are flexible enough to be used outside the context of a full Symfony2 framework-based application. 据我了解,Symfony2组件足够灵活,可以在完整的基于Symfony2框架的应用程序的上下文之外使用。

Has anyone has successfully used this particular package outside of a full Symfony2 project? 有没有人在完整的Symfony2项目之外成功使用过此特定程序包? If so, was it painless or were there some significant challenges that you had to overcome? 如果是这样,是不是很轻松?还是您必须克服一些重大挑战? I can see URL routing, and my lack of general Symfony2 knowledge, as potential pain points. 我可以看到URL路由以及缺乏Symfony2的一般知识,这是潜在的痛点。

Any advice or suggestions would be greatly appreciated. 任何意见或建议,将不胜感激。 Thanks! 谢谢!

I'm afraid you can't do it without hacking a lot. 恐怕您不做很多事情就无法做到。

I would recommend you to go for APIgility, there are some tutorials where you can the integration with ZF1. 我建议您使用API​​gility,这里有一些教程可以与ZF1集成。 You'll also get the advantages of content negotiation, auth, documentation. 您还将获得内容协商,身份验证和文档编制的优势。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM