当前位置: 动力学知识库 > 问答 > 编程问答 >

ios - Adding REST API to existing PHP website

问题描述:

I'm using some open source code to launch a game. The game is old, around 11yrs. It is a tick based web based game. It's written in php and using MySQL. Basically I want to port this game to ios, instead of using uiwebview I want to build native controls.

I know that it's bad practice to communicate directly with MySQL from an ios app. So what I want to do is add a RESTful API. I'm new to this and have scoured google for answers, does anyone have any pointers of where to start when adding an API to an existing site? It's quite a complex structure.

Thanks.

Paul.

网友答案:

My suggestion is using a framework that is guided towards building an API. I use Slim Framework for my API back end and it's pretty easy to use. If you create a separate URL for this API or include directly into the PHP project as a class it could work.

Some tutorials to get you started are

Say Hello World with Slim

RESTful services with jQuery, PHP and the Slim Framework

Writing a RESTful Web Service with Slim

Hope this helps,

Wes

分享给朋友:
您可能感兴趣的文章:
随机阅读: