2012-08-13 72 views
1

我試圖在不使用FOSTwitterBundle的情況下安裝Abraham's twitteroauth library。我想通過庫直接使用API​​。Symfony2 - 安裝TwitterAuth庫

我的問題是該庫沒有分配名稱空間。 我試圖按照這種tutorial抵達此配置:

# app/autoload.php 
$loader->registerPrefixes(array(
    // ... 
    'TwitterOAuth_' => __DIR__.'/../vendor/twitteroauth/lib', 
)); 


# vendor/twitteroauth/lib/TwitterOAuth/TwitterOAuth_TwitterOAuth.php 
require_once __DIR__.'/src/twitteroauth/twitteroauth.php'; 
class TwitterOAuth_TwitterOAuth extends TwitterOAuth 
{ 
} 

在我的控制器:

$api = new \TwitterOAuth_TwitterOAuth('asd','asd'); 

我仍然得到:

Fatal error: Class 'TwitterOAuth_TwitterOAuth' not found. 

謝謝!

回答

2

我認爲你的路徑是錯誤的。

根據你給的鏈接,隔世是:

# vendor/geshi/lib/Geshi/Geshi.php 

爲:

$geshi = new \Geshi_Geshi(); 

所以,你應該使用:

vendor/twitteroauth/lib/TwitterOAuth/TwitterOAuth.php 

,而不是

vendor/twitteroauth/lib/TwitterOAuth/TwitterOAuth_TwitterOAuth.php 
+0

是的!那是我的問題,我沒有看到,我真的很傻。非常感謝你 :) – 2012-08-13 14:50:24