douwen8118 2016-09-21 14:01
浏览 54

为什么这个require_once会失败?

I am using PEAR's Services_Facebook-0.2.14 SDK, and the first of the following lines in Facebook.php fails:

require_once 'Common.php';
require_once 'Services/Facebook/Common.php';
require_once 'Services/Facebook/Exception.php';

with the log message:

[21-Sep-2016 13:41:46 UTC] PHP Fatal error: require_once(): Failed opening required 'Common.php' (include_path='/home/thehanfw/php/Services') in /home/thehanfw/php/Services/Facebook.php on line 23

In my Facebook API client, I use the following lines to access the SDK:

ini_set("include_path", "/home/thehanfw/php/Services");
require_once "Facebook.php";

I have set the include path explicitly like this out of desperation, before my app would even find Facebook.php. The Common.php file is present, and I have commented out the require_once 'Services/Facebook/Common.php'; because Services is already the include directory, and I was getting exactly the same error with the original code.

Interesting as well is that this error is logged about 20 times in very quick succession before I get an HTTP ERR_TOO_MANY_REDIRECTS error in my client app. This is on a shared host, with PHP 5.6.22.

BREAKING: I found it funny that my client app was working fine on my dev machine though, but then I realised I had only later installed the blasted PEAR on my PC, and the app was working against an SDK directly downloaded from Facebook, named php-graph-sdk-5.0.0. I don't know if the 5.0.0 FB version vs. the 0.2.14 PEAR version, but that I've cleaned out the PEAR crap from my host, and installed the FB SDK, it works on the host as well.

  • 写回答

1条回答 默认 最新

  • doushan1863 2016-09-27 08:37
    关注

    PEAR packages code files have require_once statements that only work when you have the root package directory in your include path. In your case the include path should include at least /home/thehanfw/php/, since that's where you (manually) extracted the package into.

    Extracting PEAR packages manually is not recommended unless you really know what you are doing:

    We removed this section, because, today, manually installing a package requires a deeper understanding of the way how packages are organized and what happens during the installation process. You should read the section about the package.xml in the Developers Guide (package.xml and package.xml 2.0), if you really want install a package without the PEAR installer.

    You apparently do not, and it failed.


    The PEAR package was last released in 2010, which is 6 years ago. You are better off with the official API.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度