简体   繁体   English

在WAMP Web服务器上用PHP实现Rest API的最佳方法

[英]Best way to implement a Rest API with PHP on WAMP web server

I own a web server running Windows ( WAMP ). 我拥有一个运行Windows的Web服务器( WAMP )。 I want to know the best way to implement a Rest API (a very simple one) in order to let a user do something. 我想知道实现Rest API(一种非常简单的方法)以便让用户做某事的最佳方法。

Diagram flow: 图流:

alt text http://img215.imageshack.us/img215/6105/flowe.png 替代文字http://img215.imageshack.us/img215/6105/flowe.png

I have programming skills, in fact, I developed a web server in VB6 who process the queries and when it finds the command (http:/ serverIP /webform.php?cmd=run&item=any) it does something, but I really want to develop a solution using the WAMP server. 我具有编程技能,实际上,我在VB6中开发了一个Web服务器,该服务器处理查询,并且当它找到命令(http:/ serverIP /webform.php?cmd=run&item=any)时,它可以执行某些操作,但是我真的很想使用WAMP服务器开发解决方案。

Some people consider the solution of executing a exe when a command is detected a bad solution for security issues, but this specific project I have is for the use by some people (trusted people) who dont have intentions of hacking the server. 有人认为检测到命令时执行exe的解决方案对安全性问题是不好的解决方案,但是我拥有的这个特定项目供不希望黑客入侵服务器的某些人(受信任的人)使用。

So, what do you think? 所以你怎么看?

Remember: 记得:

  1. Its not a public API, its for some people and some programs who will use the API 它不是公共API,适用于将使用该API的某些人和某些程序
  2. Its a very simple one, only one command using POST or GET. 这是一个非常简单的命令,只有一个使用POST或GET的命令。

Thanks 谢谢

Ive just recently finished a REST API project on PHP and it was a good experience. Ive最近刚完成了一个关于PHP的REST API项目,这是一个很好的经验。 The way I see it, the fastest/easiest way to implement this is using the following elements: 我认为,实现此目的最快/最简单的方法是使用以下元素:

  • Object Oriented PHP 面向对象的PHP
  • MVC paradigm MVC范式
  • Create a request dispatcher 创建一个请求调度程序

I found this link very useful when I started, it should get you going in no time: 当我开始时,我发现此链接非常有用,它可以立即帮助您:

http://particletree.com/features/how-to-add-an-api-to-your-web-service/ http://particletree.com/features/how-to-add-an-api-to-your-web-service/

Edit: 编辑:

I didnt use this framework but it looked promising: http://tonic.sourceforge.net/ 我没有使用此框架,但看起来很有希望: http : //tonic.sourceforge.net/

Also, CakePHP supports Rest and is a neat MVC framework. 而且,CakePHP支持Rest,并且是一个简洁的MVC框架。 If you're looking to implement in no time, go with CakePHP. 如果您希望立即实现,请使用CakePHP。

Good luck! 祝好运!

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

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