Support the ongoing development of →
Packages Configuration Architecture
Last updated 1 year ago.

rezwan-hossain liked this thread


You can use any PHP library in Laravel without a service provider. What the service provider does is simplify it. In case of APIs they mostly require an api_key and api_secret. The provider should take those from the environment/configuration and provide you with a ready to use set of services. From what I see the provider should call

ChargeBee_Environment::configure(config(""), config("chargebee.api_key")); // Create a file called  chargebee.php in the config folder, fetching the values from environment.

After registering the provider you should be able to call the ChargeBee_Customer::all(...) from anywhere in the controller.

The above in unrelated to your problem. What the error is saying is that you are missing a using statement at the top of your controller code. You need to add use ChargeBee_Customer;. This won't work out of the box because PHP doesn't know where to look for this class. It's because the library doesn't comply with PS4 standard, which allows autoloading. You have to handle that yourself. To do so modify your composer.json file

    "autoload": {
        "psr-4": {
            "App\\": "app/"
        "files": [
            //Add other files you need here
        "classmap": [

After that run composer dump-autoload and see if PHP manages to find the class.

Last updated 3 years ago.

Sign in to participate in this thread!


Your banner here too?

E-Cadima embercadima Joined 22 May 2020


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.