How to disable “always include” class in Composer autoload_static.php

Tags: , ,

Composer in autoload_static.php use class that I don’t need them in every app request.

'd5fa61a7f6cbc1df09dd4df84549a2dc' => __DIR__ . '/..' . '/rospdf/pdf-php/src/Cpdf.php',
'2d15964294879de66053d54f6bde65d7' => __DIR__ . '/..' . '/rospdf/pdf-php/src/Cezpdf.php',

How to remove them from this autoload file? I can delete/comment them manually but every Composer update this file is re-generated.

I try to add in my main composer.json: “exclude-from-classmap”: [“vendor/rospdf/pdf-php/src/”] & run composer dump-autoload bo those class are still in there.


You can trick the autoloader of composer and let him think those are already loaded:


// Setting global variable:
$GLOBALS["__composer_autoload_files"] = [
    "d5fa61a7f6cbc1df09dd4df84549a2dc" => true,
    "2d15964294879de66053d54f6bde65d7" => true,

require "vendor/autoload.php";

But this needs to happen before the vendor/autoload.php is included.

Source: stackoverflow