2015-10-04 98 views
1

我正在嘗試使用Cartalyst,一個用於條帶付款的全面PHP庫。這裏是他們的文檔鏈接:https://cartalyst.com/manual/stripe/1.0。這裏是我試圖去工作代碼:自動加載PHP類時發生致命錯誤

$stripe = Stripe::make('your-stripe-api-key'); 
$customers = $stripe->customers()->all(); 

foreach ($customers['data'] as $customer) { 
    var_dump($customer['email']); 
} 

當我運行上面的代碼(在我真正的代碼,我有我的API插入),我收到以下錯誤:Fatal error: Class 'Stripe' not found in on line 247。我已經檢查了一切,我知道要檢查,我似乎無法弄清楚問題所在。我已經「自動加載」Stripe Cartalyst庫和St​​ripe庫。

而且,這裏是產生自動加載的文件我作曲代碼:

{ 
    "require": { 
     "cartalyst/stripe": "~1.0", 
     "stripe/stripe-php": "3.*" 
    } 
} 

任何幫助,不勝感激!如果您需要更多信息,請告訴我。

+0

@PedroLobito我該如何解決這個問題?我無法重命名這些軟件包,也不能下載。感謝您的幫助。 – three3

+0

@PedroLobito感謝您的鏈接和示例代碼。我已閱讀鏈接,但我也嘗試過您的示例代碼,但仍收到相同的錯誤消息:'Class'Stripe''not found in'。 – three3

+0

重複的http://stackoverflow.com/questions/28921871/fatal-error-class-stripe-not-found-in-c-wamp-www –

回答

-1

它需要的命名空間\Stripe,請嘗試:

\Stripe\Stripe::setApiKey('your-stripe-api-key'); 
+0

好吧,所以我已經嘗試了這兩個代碼片段。當我試過'\ Stripe \ Stripe :: setApiKey('your-stripe-api-key');',它刪除了我接收到的原始錯誤,但是我沒有收到新的錯誤:'調用成員函數customers (),這是這行代碼:'$ customers = $ stripe-> customers() - > all();'。 – three3

+0

這裏是我試圖運行的確切代碼的鏈接:https://cartalyst.com/manual/stripe/1.0#retrieve-all-customers-2 – three3

+0

這是一個新問題,請打開一個新的問題:) –

相關問題