Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

frenksjr's avatar

Class not found

Why I got an error "Class not found" ?

code :

<?php namespace Acme\Billing;

use Stripe;
use Stripe_Charge;
use Config;

class StripeBilling implements BillingInterface {

    public function __construct()
    {
        Stripe::setApiKey(Config::get('stripe.secret_key'));
    }

I installed these classess with composer..

0 likes
3 replies
michaeldyrynda's avatar

Is Stripe and Stripe_Charge the full namespaced path for those classes?

I assume not, so PHP is trying to find the class in your current namespace i.e. Acme\Billing\Stripe.

A quick look at their PHP library's readme suggests you'll want to use Stripe\Stripe; and use Stripe\Charge;.

From there, you'll be able to use the class names Stripe and Charge.

1 like
willvincent's avatar

Yeah, @deringer is right, it should most likely be:

use \Stripe\Stripe;
use \Stripe\Charge;
use Config;

Though you may need to specify a different namespace for the config class as well.

Please or to participate in this conversation.