如何在 PHP 中创建 REST API? [英] How do you create a REST API in PHP?
问题描述
我一直在开发游戏网站,并计划添加一个 API,让开发人员为网站创建游戏.唯一的问题是您如何创建 API,更具体地说是使用 PHP 或任何其他可以开发 API 的语言的 REST API?
I've been developing gaming site and planning to add an API to let developers create games for the site. The only problem is how do you create an API more specifically a REST API in PHP or any other language that could develop APIs?
抱歉,我刚接触 API 开发.
Sorry, just new in API Development.
感谢任何帮助.
推荐答案
当您了解基础知识时,这很容易.基本上,您希望控制器映射到修改数据的操作,无论数据是在数据库、XML 文件、CSV 文件还是文本文件中都取决于您的模型.
It's pretty easy when you understand the fundamentals. Basically you want controllers mapped to actions that modify data, whether that data's in a database, XML file, CSV file, text file depends on your models.
我创建了一个简单的 API 框架入门程序,您可以查看并开始使用:https://github.com/martinbean/api 框架
I created a simple API framework starter that you can take a look at and get started with: https://github.com/martinbean/api-framework
这篇关于如何在 PHP 中创建 REST API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!