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

smick's avatar
Level 1

Undefined constant 'Laravel\Cashier\CashierServiceProvider'

Hey Guys,

Having issues getting the service provider loaded in a fresh install of Laravel 5.3.

added cashier to my composer.json file:

"require": {
        "php": ">=5.6.4",
        "laravel/framework": "5.3.*",
        "laravel/cashier": "~7.0"
    },

ran composer update with the following output:

Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing stripe/stripe-php (v3.23.0)
    Loading from cache

  - Installing phenx/php-svg-lib (0.1)
    Loading from cache

  - Installing phenx/php-font-lib (0.4)
    Loading from cache

  - Installing dompdf/dompdf (v0.7.0)
    Loading from cache

  - Installing laravel/cashier (v7.0.3)
    Loading from cache

Writing lock file
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
Generating optimized class loader
php artisan
The compiled class file has been removed.

Verified, CashierServiceProvider.php appear in vendor under: vendor/laravel/cashier/src/

Registered the provider class in config/app.php under the Package Service Providers section:

/*
  * Package Service Providers...
 */
Laravel\Cashier\CashierServiceProvider,

ran php artisan as a sanity check and get the following error:

PHP Fatal error:  Undefined constant 'Laravel\Cashier\CashierServiceProvider' in /home/vagrant/Code/test_project/website/config/app.php on line 169
PHP Stack trace:
PHP   1. {main}() /home/vagrant/Code/test_project/website/artisan:0
PHP   2. Illuminate\Foundation\Console\Kernel->handle() /home/vagrant/Code/test_project/website/artisan:36
PHP   3. Illuminate\Foundation\Console\Kernel->bootstrap() /home/vagrant/Code/test_project/website/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:113
PHP   4. Illuminate\Foundation\Application->bootstrapWith() /home/vagrant/Code/test_project/website/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:267
PHP   5. Illuminate\Foundation\Bootstrap\LoadConfiguration->bootstrap() /home/vagrant/Code/test_project/website/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:203
PHP   6. Illuminate\Foundation\Bootstrap\LoadConfiguration->loadConfigurationFiles() /home/vagrant/Code/test_project/website/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php:38
PHP   7. require() /home/vagrant/Code/test_project/website/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php:60

Fatal error: Undefined constant 'Laravel\Cashier\CashierServiceProvider' in /home/vagrant/Code/test_project/website/config/app.php on line 169

Call Stack:
    0.0005     226048   1. {main}() /home/vagrant/Code/test_project/website/artisan:0
    0.1492    3073320   2. Illuminate\Foundation\Console\Kernel->handle() /home/vagrant/Code/test_project/website/artisan:36
    0.1492    3073448   3. Illuminate\Foundation\Console\Kernel->bootstrap() /home/vagrant/Code/test_project/website/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:113
    0.1492    3073616   4. Illuminate\Foundation\Application->bootstrapWith() /home/vagrant/Code/test_project/website/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:267
    0.1681    3363784   5. Illuminate\Foundation\Bootstrap\LoadConfiguration->bootstrap() /home/vagrant/Code/test_project/website/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:203
    0.1733    3392416   6. Illuminate\Foundation\Bootstrap\LoadConfiguration->loadConfigurationFiles() /home/vagrant/Code/test_project/website/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php:38
    0.2205    3664464   7. require('/home/vagrant/Code/test_project/website/config/app.php') /home/vagrant/Code/test_project/website/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php:60

Any idea why this would be, or how to resolve it? Something with autoloading/namespacing maybe?

0 likes
2 replies
smick's avatar
Level 1

Figured it out.

/*
 * Package Service Providers...
 */
Laravel\Cashier\CashierServiceProvider,

should be:

/*
 * Package Service Providers...
 */
Laravel\Cashier\CashierServiceProvider::class,
tykus's avatar
tykus
Best Answer
Level 104
Laravel\Cashier\CashierServiceProvider::class
1 like

Please or to participate in this conversation.