【发布时间】:2012-02-22 11:35:43
【问题描述】:
我的 PHP 5 在 IIS 7.5 中运行良好,并且我已经在我的共享 linux 托管环境中使用 Restler.php 成功实现了一个 PHP api。
为了缩短开发时间,我决定将页面本地化到我的 Windows 环境中,但无法使用 Restler.php 让 api 与 IIS 中的 Rest 功能一起使用。
我搜索了帮助配置 IIS 的文档,甚至搜索了告诉我需要安装 URL 重写工具的语句,但找不到任何可以提供帮助的东西,我也无法让 API 返回任何内容,甚至“你好”世界”。
【问题讨论】:
-
使用包含
index.phpRestler 的网址应该可以在 IIS 上开箱即用。我主要在Mac上。将在 IIS 上对其进行测试并在文档中包含步骤 -
我已经完成了以下测试,不确定是否相关,但希望对您有所帮助。测试是 url:
localhost/virtualdirectory/api。注释掉 index.php 中的所有行,并且 onyl 做了一个回应。这表明 PHP 正在 VD 中工作。 -
Echo 工作正常,所以我逐行取消注释 index.php
require_once 'restler.php'; $r = new Restler(); $r->addAPIClass('Say'); $r->handle();在最后一行 handle();我收到此错误PHP Strict Standards: Only variables should be passed by reference in C:\Backup\Web\virtualdirectory\api\restler.php on line 2 PHP Strict Standards: call_user_func() expects parameter 1 to be a valid callback, non-static method DefaultResponse::__formatError() should not be called statically in C:\Backup\Web\virtualdirectory\api\restler.php on line 2 -
下载了最新版本的 Luracast-Restler-v2.0.1-22-gc334e7e 并使用了普通的 restler.php 而不是最小的,现在得到错误:
PHP Strict Standards: call_user_func() expects parameter 1 to be a valid callback, non-static method DefaultResponse::__formatError() should not be called statically in C:\Backup\Web\virtualdirectory\api\restler.php on line 293这行显示为array($this->response, '__formatError'), $status_code, $message)。 -
请问您使用的 PHP 版本,我猜它可能低于 5.3。我刚刚在 IIS 7.5 和 PHP 5.3 上测试了 restler 示例,它们在 URL 中使用 index.php 渲染得很好。稍后我将为漂亮的 url 创建 Web.config 示例。 Restler 是为 PHP 5.3 编写的,并且应该使用战斗.php 文件向后兼容到 5.0。