Skip to content
Advertisement

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

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.

Advertisement

Answer

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

<?php

// 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.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement