douxiong0668 2014-10-18 23:23 采纳率: 100%
浏览 39

简单的PHP名称空间问题

Trying to implement a 3rd-party-lib with PHP 5.3.9-ZS5.6.0 and the lib uses namespaces. The code where I want to use the lib doesn't. So i have:

  • facebook.php
  • Mute

(Mute is the folder of the lib)

In facebook.php I try:

$app = new \Mute\Facebook\App();

Resulting in: Fatal error: Class 'Mute\Facebook\App' not found in...

The files are all in place. I can say:

use \Mute\Facebook\App;

without getting any error/warning... What am I missing?

When I require the "App.php" via require_once I get the next error: Fatal error: Interface 'Mute\Facebook\Bases\AccessToken' not found in [...]/Mute/Facebook/App.php

Mute/Facebook/App.php:

<?php
namespace Mute\Facebook;

use Closure;
use Exception;
use Mute\Facebook\Bases\AccessToken;
use Mute\Facebook\Bases\Batchable;
use Mute\Facebook\Bases\Configurable;
use Mute\Facebook\Bases\Requestable;
use Mute\Facebook\Bases\RequestHandler;
use Mute\Facebook\Exception\CurlException;
use Mute\Facebook\Exception\GraphAPIException;
use Mute\Facebook\Exception\HTTPException;
use Mute\Facebook\Exception\InvalidArgumentException;
use Mute\Facebook\Exception\OAuthSignatureException;
use Mute\Facebook\Util;

class App implements AccessToken, Batchable, Configurable, Requestable, RequestHandler
{ [...]
  • 写回答

1条回答 默认 最新

  • douxian7808 2014-10-19 00:35
    关注
    function __autoload($class_name) {
        require_once str_replace('\\', '/', $class_name) . '.php';
    }
    

    I created a __autoload function to "magically" require all files I need. Totally forgot about this method >.<

    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改