Closed TussendoorHQ closed 1 year ago
I suspect what's happening is that composer/composer
is an explicit require
dependency of one of your dependencies (a full composer.json
would be helpful here) and so it is being copied and then deleted. An exclusion rule should be written for the Composer autoload files.
You could try setting the target_directory
to vendor
, and use the exclude_from_prefix
setting for your two exclusions. Then it will prefix in-place and won't delete anything at all.
require_once __DIR__ . '/vendor/prefixed/autoload.php';
I think maybe that line won't be necessary after composer dump-autoload
is run because you're using a sub-directory of vendor
to copy the files to, and dump-autoload
should scan the entire vendor
directory
find vendor -type d -empty -delete
I've been meaning to add this to Strauss itself.
Thanks for the astonishing fast reply Brian!
I searched for the requirement that had composer/composer
in their requirements and funnily enough it was the strauss package itself! After switching to the .phar file the problem was resolved. I needed some extra changes too (also based on your reply). So for anybody coming accross this, these are my changes:
brianhenryie/strauss
from my requirements.prefixer.sh
from vendor/bin/strauss
to: php strauss.phar
target_directory
to: vendor
exclude_from_copy
to exclude_from_prefix
in my config to acommodate for the target_directory
change.autoload
config as per issue 34 and this reply. (#34)
"classmap": [
"vendor"
]
require_once __DIR__ . '/vendor/autoload.php';
The issue mentioned here is resolved. Still running into another issue where a specific directory (/lazy) of nesbot/carbon
doesnt get prefixed. But I will create a new issue for it as it is not related.
First of all; thank you for this package. It works wonderfull.
Although I'm running into an issue when using
delete_vendor_packages
in the config. The reason I want to use this is to cleanup my vendor directory so only specific dependencies stay there and only those will be autoloaded using composer. That is because I use the composer autoloader for some packages that are not using namespaces and I also use the composer autoloader to load my custom plugin classes.That means I include both of the autoloaders in my plugin like so:
This is my config in the composer.json:
As you can see I am running a custom shell script after the regular composer commands like
install
andupdate
. The shell script is looking like this:So after running
vendor/bin/strauss
myvendor
directory is looking like this. (leaving some stuff out for simplicity):All good until now. But the next step is to dump the composer autoload by
composer dump-autoload
and this is where I run into the following errors:This is originating from
vendor/bin/composer
on line 120. That is the following:include __DIR__ . '/..'.'/composer/composer/bin/composer';
This file isnt present anymore after using
delete_vendor_packages
and it also is not in the newvendor/prefixed/composer
directory. I've tried excluding thecomposer/composer
package by adding it to theexclude_from_copy
config but that resulted in even more errors.I believe this error could be resolved when the composer directory would not be copied to the
target_directory
. This directory should also not be cleaned so the file that is being searched for will still be present.I've got the following questions:
target_directory
at all?