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

Digisol's avatar

Trouble Autoloading a composer package

I have just installed dompdf

composer require dompdf/dompdf

The package installation completes with no errors, however I can't access it. I tried dumping my autoload

composer dumpautoload

and the package isn't present in the autoload. Am I missing a step to add it?

  barryvdh/laravel-ide-helper ........................ DONE
  laravel/sail ............................................................. DONE
  laravel/sanctum ................................................. DONE
  laravel/tinker ........................................................ DONE
  laravel/ui ................................................................ DONE
  nesbot/carbon ..................................................... DONE
  nunomaduro/collision ...................................... DONE
  nunomaduro/termwind ................................... DONE
  spatie/laravel-ignition ..................................... DONE
0 likes
7 replies
Digisol's avatar

@dev-chahal Just tried it and the package still isn't present in the autoload.

chahal's avatar

Can you please share composer.json

Digisol's avatar

@dev-chahal

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "require": {
        "php": "^8.0.2",
        "doctrine/dbal": "^3.3",
        "dompdf/dompdf": "^2.0",
        "guzzlehttp/guzzle": "^7.4",
        "jenssegers/mongodb": "^3.9",
        "laravel/framework": "^9.2",
        "laravel/sanctum": "^2.14.1",
        "laravel/tinker": "^2.7",
        "laravel/ui": "^3.4"
    },
    "require-dev": {
        "barryvdh/laravel-ide-helper": "^2.12",
        "fakerphp/faker": "^1.9.1",
        "laravel/sail": "^1.0.1",
        "mockery/mockery": "^1.4.4",
        "nunomaduro/collision": "^6.1",
        "phpunit/phpunit": "^9.5.10",
        "spatie/laravel-ignition": "^1.0"
    },
    "autoload": {

        "psr-4": {
            "App\": "app/",
            "Database\Factories\": "database/factories/",
            "Database\Seeders\": "database/seeders/"
        },
        "files": [
            "app/Helpers/helpers.php"
        ]
    
    },
    
    "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"
        ]
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

Sinnbeck's avatar

@Digisol seems to be installed then. What error are you getting when you use it?

Digisol's avatar

It was saying that I was using a Library that didn't exist (I believe undefined, don't have the exact error anymore) I removed it and installed it again and it started working, so I'm not sure what the problem was.

Sinnbeck's avatar

@Digisol ok. If the problem is solved please mark a best answer to set the thread as solved

Please or to participate in this conversation.