自动加载 PHP 类时出现致命错误 [英] Getting a fatal error when autoloading a PHP class

查看:39
本文介绍了自动加载 PHP 类时出现致命错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 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),我收到以下错误:致命错误:第 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,试试:

 StripeStripe::setApiKey('your-stripe-api-key');

这篇关于自动加载 PHP 类时出现致命错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆