2015-10-04 101 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

这是一个新问题,请打开一个新的问题:) –

相关问题