0

我已经使用作曲家安装了restler。我已经为它设置了一个虚拟主机。我可以localhost在我的浏览器中访问我的页面,它会显示一些信息页面,但是一旦我尝试其中一个 API,我就会得到一个 server 500 error

我的 PHP 日志说:

Function    main
Error Type  E_ERROR
Source File /public/examples/_001_helloworld/index.php : 18
Error String    Class 'Luracast\Restler\Restler' not found

我直接使用项目中的示例代码。看起来它有 require_once'../../../vendor/restler.php'并且似乎仍然有 500 个错误。

我在 Mac 上使用 PHP 5.4.16。

更新

这是我所有的日志:

[05-Sep-2013 17:05:09 America/Denver] PHP Warning:  include(/Users/ChrisLondon/composer/autoload_classmap.php): failed to open stream: No such file or directory in /Users/ChrisLondon/personal/SuperfyMe/vendor/Luracast/Restler/AutoLoader.php on line 432
[05-Sep-2013 17:05:09 America/Denver] PHP Warning:  include(): Failed opening '/Users/ChrisLondon/composer/autoload_classmap.php' for inclusion (include_path='.:/usr/local/zend/share/ZendFramework/library:/usr/local/zend/share/pear:/opt/local/lib/php') in /Users/ChrisLondon/personal/SuperfyMe/vendor/Luracast/Restler/AutoLoader.php on line 432
[05-Sep-2013 17:05:09 America/Denver] PHP Warning:  include(/Users/ChrisLondon/composer/autoload_namespaces.php): failed to open stream: No such file or directory in /Users/ChrisLondon/personal/SuperfyMe/vendor/Luracast/Restler/AutoLoader.php on line 432
[05-Sep-2013 17:05:09 America/Denver] PHP Warning:  include(): Failed opening '/Users/ChrisLondon/composer/autoload_namespaces.php' for inclusion (include_path='.:/usr/local/zend/share/ZendFramework/library:/usr/local/zend/share/pear:/opt/local/lib/php') in /Users/ChrisLondon/personal/SuperfyMe/vendor/Luracast/Restler/AutoLoader.php on line 432
[05-Sep-2013 17:05:09 America/Denver] PHP Warning:  array_values() expects parameter 1 to be array, boolean given in /Users/ChrisLondon/personal/SuperfyMe/vendor/Luracast/Restler/AutoLoader.php on line 154
[05-Sep-2013 17:05:09 America/Denver] PHP Warning:  array_merge(): Argument #2 is not an array in /Users/ChrisLondon/personal/SuperfyMe/vendor/Luracast/Restler/AutoLoader.php on line 155
[05-Sep-2013 17:05:09 America/Denver] PHP Warning:  array_merge(): Argument #1 is not an array in /Users/ChrisLondon/personal/SuperfyMe/vendor/Luracast/Restler/AutoLoader.php on line 155
[05-Sep-2013 17:05:09 America/Denver] PHP Warning:  array_map(): Argument #2 should be an array in /Users/ChrisLondon/personal/SuperfyMe/vendor/Luracast/Restler/AutoLoader.php on line 166
[05-Sep-2013 17:05:09 America/Denver] PHP Warning:  array_filter() expects parameter 1 to be array, null given in /Users/ChrisLondon/personal/SuperfyMe/vendor/Luracast/Restler/AutoLoader.php on line 166
[05-Sep-2013 17:05:09 America/Denver] PHP Warning:  natsort() expects parameter 1 to be array, null given in /Users/ChrisLondon/personal/SuperfyMe/vendor/Luracast/Restler/AutoLoader.php on line 167
[05-Sep-2013 17:05:09 America/Denver] PHP Warning:  array_unique() expects parameter 1 to be array, null given in /Users/ChrisLondon/personal/SuperfyMe/vendor/Luracast/Restler/AutoLoader.php on line 170
[05-Sep-2013 17:05:09 America/Denver] PHP Warning:  implode(): Invalid arguments passed in /Users/ChrisLondon/personal/SuperfyMe/vendor/Luracast/Restler/AutoLoader.php on line 170
[05-Sep-2013 17:05:09 America/Denver] PHP Fatal error:  Class 'Luracast\Restler\Restler' not found in /Users/ChrisLondon/personal/SuperfyMe/public/examples/_001_helloworld/index.php on line 19

似乎它试图在这里找到自动加载类:/Users/ChrisLondon/composer/autoload_classmap.php但文件实际上在这里:/Users/ChrisLondon/personal/SuperfyMe/vendor/composer/autoload_classmap.php

4

1 回答 1

0

解决了我的问题。

事实证明,因为我有一个名为的文件夹composer/,它恰好是 Restler 应用程序所在的两个文件夹,它破坏了 Restler 自动加载器。要解决此问题,需要执行以下操作之一:

1)没有任何文件夹命名为composer/两个文件夹,从 Restler 应用程序所在的位置开始

line 1382) 修改 Restler 自动加载器以跳过该文件夹(在本文发表时,您可以注释掉/vendor/Luracast/Restler/Autoloader.php

我在 GitHub 上提出了一个更优雅的解决方案:

问题:https ://github.com/Luracast/Restler/issues/195

拉取请求:https ://github.com/Luracast/Restler/pull/196

当其他人发现这篇文章时,希望这个问题将在未来版本的 Restler 中得到解决。

于 2013-09-06T02:49:15.380 回答