[Bug]: Composer class map generation
Platform
macOS
Operating system version
macOS 15.5
System architecture
ARM64 (M1, M2, etc)
Herd Version
1.20.3 (Build: 48)
PHP Version
8.4.8
Bug description
Hi,
I am trying to use Herd and I encountered one issue. I am using composer autoload via class map generation. It is generated to vendor/composer/autoload_classmap.php and this file is loaded afterwards via new \ReflectionClass(ClassLoader::class). The issue is, that this reflection loads Herd's PHAR isolated composer with its own class map.
Is there any solution for this?
Thanks.
Steps to reproduce
No response
Relevant log output
Could you tell me how to reproduce this and which issue this generates for you?
Reproduce: use composer autoloading. Issue: autoloading is dependent on vendor/composer files (e.g. ClassLoader class or autoload_classmap.php) but these cannot be used since Herd injects isolated composer.
I'm not really sure which issue you mean. I created a dummy repository that uses classmap autoloading: https://github.com/mpociot/herd-issue-reproduce-1448
Running php index.php in the CLI works fine and opening the project in the browser as well.
Composer generates a class map to project/site vendor/composer directory, but if I dump path to this after request I am getting phar:///Applications/Herd.app/Contents/Resources/valet/dump.phar/vendor/composer/autoload_classmap.php and this class map is completely different.
To be more clear, I run (herd) composer dump-autoload which generates correct vendor/composer/autoload_classmap.php, but afterwards on the site request the phar:///Applications/Herd.app/Contents/Resources/valet/dump.phar/vendor/composer/autoload_classmap.php is loaded which is completely different class map from the generated one. It contains only a few Herd tools related classes etc.
I noticed that the request is being called through Applications/Herd.app/Contents/Resources/valet/server.php and only after that my index.php is processed, so is it possible that the autoload.php is required somewhere inside server.php and afterwards my autoload.php required inside my index.php is using ClassLoader class already defined by Herd. When I am tying to get path to my composer directory using ClassLoader class reflection, I am getting path to Herd composer.
I was able at least to workaround this issue with disabling dumps via configuring dumps: false in Library/Application Support/Herd/config. However, how can I disable it persistently, because after a reboot the config resumes?