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

Fahim1990's avatar

Php Artisan doesn't work after installing Laravel/sanctum

Artisan doesn't work after installing Laravel/sanctum. I have already tried composer: dump-autoload, composer install --no-script and composer update. But i still get the following error message:

PHP Fatal error:  Uncaught Error: Class "Illuminate\Foundation\Application" not found in C:\xampp\htdocs\api\bootstrap\app.php:7 Stack trace: #0 C:\xampp\htdocs\api\artisan(14): require_once() #1 {main}   thrown in C:\xampp\htdocs\api\bootstrap\app.php on line 7

When i use the command: php artisan

1 like
13 replies
Fahim1990's avatar

@vincent15000 I found the mistake. While Sanctum was installed, Composer deleted files in the vendor file. I had to manually add the deleted files, and everything worked fine.

1 like
Fahim1990's avatar

@vincent15000 This is the output i get for the command:

php artisan install:api C:\composer\composer.json has been updated Running composer update laravel/sanctum Loading composer repositories with package information Updating dependencies Nothing to modify in lock file Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 1 install, 0 updates, 37 removals

  • Removing theseer/tokenizer (1.2.3)
  • Removing symfony/yaml (v7.2.5)
  • Removing staabm/side-effects-detector (1.0.5)
  • Removing sebastian/version (5.0.2)
  • Removing sebastian/type (5.1.2)
  • Removing sebastian/recursion-context (6.0.2)
  • Removing sebastian/object-reflector (4.0.1)
  • Removing sebastian/object-enumerator (6.0.1)
  • Removing sebastian/lines-of-code (3.0.1)
  • Removing sebastian/global-state (7.0.2)
  • Removing sebastian/exporter (6.3.0)
  • Removing sebastian/environment (7.2.0)
  • Removing sebastian/diff (6.0.2)
  • Removing sebastian/complexity (4.0.1)
  • Removing sebastian/comparator (6.3.1)
  • Removing sebastian/code-unit-reverse-lookup (4.0.1)
  • Removing sebastian/code-unit (3.0.3)
  • Removing sebastian/cli-parser (3.0.2)
  • Removing psy/psysh (v0.12.8)
  • Removing phpunit/phpunit (11.5.17)
  • Removing phpunit/php-timer (7.0.1)
  • Removing phpunit/php-text-template (4.0.1)
  • Removing phpunit/php-invoker (5.0.1)
  • Removing phpunit/php-file-iterator (5.1.0)
  • Removing phpunit/php-code-coverage (11.0.9)
  • Removing phar-io/version (3.2.1)
  • Removing phar-io/manifest (2.0.4)
  • Removing nunomaduro/collision (v8.8.0)
  • Removing nikic/php-parser (v5.4.0)
  • Removing myclabs/deep-copy (1.13.0)
  • Removing mockery/mockery (1.6.12)
  • Removing laravel/tinker (v2.10.1)
  • Removing laravel/sail (v1.41.0)
  • Removing laravel/pint (v1.21.2)
  • Removing hamcrest/hamcrest-php (v2.0.1)
  • Removing filp/whoops (2.18.0)
  • Removing fakerphp/faker (v1.24.1)
  • Installing laravel/sanctum (v4.0.8): Extracting archive 0/28 [>---------------------------] 0% 10/28 [==========>-----------------] 35% 20/28 [====================>-------] 71% 28/28 [============================] 100% Generating autoload files 52 packages you are using are looking for funding. Use the composer fund command to find out more! No security vulnerability advisories found. INFO Published API routes file.

And after that php artisan doesnt work. Until you add the deleted files back to the vendor file.

1 like
JussiMannisto's avatar
Level 50

@Fahim1990 You don't add deleted files to the vendor directory manually. That directory holds all 3rd party dependencies that are installed, based on your composer.json file, when you run composer update. What does your composer.json look like?

But why is your composer.json loaded from the path C:\composer\composer.json? That looks really strange. Is your project in the path C:\composer\?

2 likes
Fahim1990's avatar

@JussiMannisto

{ "$schema": "https://getcomposer.org/schema.json", "name": "laravel/laravel",

"type": "project",
"description": "The skeleton application for the Laravel framework.",

"keywords": ["laravel", "framework"],
"license": "MIT",

"require": {
    "php": "^8.2",
    "laravel/framework": "^12.0",
    "laravel/tinker": "^2.10.1"
},

"require-dev": {
    "fakerphp/faker": "^1.23",
    "laravel/pail": "^1.2.2",
    "laravel/pint": "^1.13",
    "laravel/sail": "^1.41",
    "mockery/mockery": "^1.6",
    "nunomaduro/collision": "^8.6",
    "phpunit/phpunit": "^11.5.3"
},

"autoload": {
    "psr-4": {
        "App\\": "app/",
        "Database\\Factories\\": "database/factories/",
        "Database\\Seeders\\": "database/seeders/"
    }
},

"autoload-dev": {
    "psr-4": {
        "Tests\\": "tests/"
    }
},

"scripts": {
    "post-autoload-dump": [
        "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
        "@php artisan package:discover --ansi"
    ],

    "post-update-cmd": [
        "@php artisan vendor:publish --tag=laravel-assets --ansi --force"
    ],

    "post-root-package-install": [
        "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],

    "post-create-project-cmd": [
        "@php artisan key:generate --ansi",
        "@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
        "@php artisan migrate --graceful --ansi"
    ],

    "dev": [
        "Composer\\Config::disableProcessTimeout",
        "npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite"
    ]
},

"extra": {
    "laravel": {
        "dont-discover": []
    }
},

"config": {
    "optimize-autoloader": true,
    "preferred-install": "dist",
    "sort-packages": true,
    "allow-plugins": {
        "pestphp/pest-plugin": true,
        "php-http/discovery": true
    }
},

"minimum-stability": "stable",
"prefer-stable": true

}

1 like
Fahim1990's avatar

@JussiMannisto Wait a minute you are right. I didnt see it. No its not in the composer file. Yes, composer was loading the wrong json file. Thx for the advise. This was the real problem. No manually adding files necessary.

1 like
vincent15000's avatar

@Fahim1990 Yes, it would have been very strange because composer install never deletes packages.

1 like
JussiMannisto's avatar

@vincent15000 Sure it does. If a dependency isn't in composer.lock (or composer.json), it gets removed when you run composer install.

1 like
vincent15000's avatar

@JussiMannisto Yes but only if you have changed the content of the composer.json / composer.lock files manually ... what you should never do.

JussiMannisto's avatar

@vincent15000 It happens all the time, and not because anyone's editing the lock file manually. You pull the latest changes from GitHub, then run composer install to sync the vendor packages. If a package has been removed, it gets deleted.

Also, there's nothing wrong with editing composer.json manually.

1 like
maxxd's avatar

@vincent15000 It apparently can, as evidenced by the AWS worst composer script ever. I'm not sure I could tally the number of hours this took some of my coworkers and me to figure out the fact that some complete shithead had made this possible.

That's not to say I think that's what happening here because I didn't see the same behavior after installing sanctum, but it's possible something else in the composer file is dumping things.

1 like
vincent15000's avatar

@JussiMannisto Oh ... Yes sure, but in this case, it means that the deleted package is no more used. Composer doesn't delete any package that is a dependency for another package.

Please or to participate in this conversation.