简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM