自动加载PHP类时出现致命错误 [英] Getting a fatal error when autoloading a PHP class
问题描述
我正在尝试使用Cartalyst,一个用于Stripe付款的综合PHP库.这是他们文档的链接: https://cartalyst.com/manual/stripe/1.0.这是我要开始工作的代码:
I am attempting to use Cartalyst, a comprehensive PHP Library for Stripe payments. Here is a link to their documentation: https://cartalyst.com/manual/stripe/1.0. Here is the code I am trying to get to work:
$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库和Stripe库.
When I run the code above (in my real code I have my api inserted), I receive the following error: Fatal error: Class 'Stripe' not found in on line 247
. I have triple-checked everything I know to check and I cannot seem to figure out what the issue is. I have "autoloaded" the Stripe Cartalyst library and the Stripe library.
此外,这是生成自动加载文件的我的作曲者代码:
Also, here is my composer code that is generating the autoload files:
{
"require": {
"cartalyst/stripe": "~1.0",
"stripe/stripe-php": "3.*"
}
}
推荐答案
它需要名称空间\Stripe
,请尝试:
It needs the namespace \Stripe
, try:
\Stripe\Stripe::setApiKey('your-stripe-api-key');
这篇关于自动加载PHP类时出现致命错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!