问题
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']);
}
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.*"
}
}
回答1:
It needs the namespace \Stripe
, try:
\Stripe\Stripe::setApiKey('your-stripe-api-key');
来源:https://stackoverflow.com/questions/32939034/getting-a-fatal-error-when-autoloading-a-php-class