steevanb / doctrine-read-only-hydrator

Add SimpleObject and ReadOnly hydrators do Doctrine.
GNU General Public License v3.0
57 stars 14 forks source link

Composer install failing with autoload optimization #8

Closed renatogcarvalho closed 3 years ago

renatogcarvalho commented 6 years ago

On a Symfony project, running "composer install -o" gives the error below:

> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
PHP Fatal error:  Class 'ComposerOverloadClass\steevanb\DoctrineReadOnlyHydrator\Hydrator\ReadOnlyHydrator' not found in /var/www/app/vendor/steevanb/doctrine-read-only-hydrator/ComposerOverloadClass/Hydrator/ReadOnlyHydrator.php on line 11
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the symfony-scripts event terminated with an exception

[RuntimeException]                                                                                                                                   
  An error occurred when executing the "'cache:clear --no-warmup'" command:                                                                            
  PHP Fatal error:  Class 'ComposerOverloadClass\steevanb\DoctrineReadOnlyHydrator\Hydrator\ReadOnlyHydrator' not found in /var/www/app/vendor/steevanb/doctrine-read-only-hydrator/ComposerOverloadClass/Hydrator/ReadOnlyHydrator.php on line 11

To circumvent this issue I have to run:

composer install; composer dump-autoload -o

However, none of the commands work after this even though the application was installed:

$ bin/console cache:clear

 // Clearing the cache for the dev environment with debug true                                                          

PHP Fatal error:  Class 'ComposerOverloadClass\steevanb\DoctrineReadOnlyHydrator\Hydrator\ReadOnlyHydrator' not found in /var/www/app/vendor/steevanb/doctrine-read-only-hydrator/ComposerOverloadClass/Hydrator/ReadOnlyHydrator.php on line 11

Any ideas on how I can get this fixed?

Best Regards,

Renato.

renatogcarvalho commented 6 years ago

To circumvent this issue my temporary solution was (I hope until we can get this fixed) set "exclude-from-classmap" in Composer.json: https://getcomposer.org/doc/04-schema.md#exclude-files-from-classmaps

"autoload": {
    "psr-4": {
        "": "src/"
    },
    "classmap": [
        "app/AppKernel.php",
        "app/AppCache.php"
    ],
    "exclude-from-classmap": [
        "vendor/steevanb/doctrine-read-only-hydrator/ComposerOverloadClass/Hydrator/ReadOnlyHydrator.php",
        "vendor/steevanb/doctrine-read-only-hydrator/ComposerOverloadClass/Hydrator/SimpleObjectHydrator.php"
    ]
}
renatogcarvalho commented 6 years ago

Hello folks,

Any ideas here? Is the "exclude-from-classmap" route the only way to circumvent this issue?

habashyjr commented 6 years ago

+1 Happens only with me on different environments than prod and dev

steevanb commented 6 years ago

I think you have a misstake in your configuration.

DoctrineReadOnlyHydrator could be used with ComposerOverloadClass, to show detailed times in Symfony WebProfiler.

But in prod env, you should not use ComposerOverloadClass with DoctrineReadOnlyHydrator, as it's not usefull.

Could you please show me your composer.json ?

maxhelias commented 3 years ago

https://github.com/steevanb/doctrine-read-only-hydrator/pull/18 should fix the problem as well