box2 icon indicating copy to clipboard operation
box2 copied to clipboard

Box as a composer dependency cannot find the correct autoload.php

Open tomzx opened this issue 8 years ago • 3 comments

I'm not sure if this change actually breaks existing behavior, but I think the idea was that if you found a composer.json file, you wanted to exit the do-while loop, not exit only when the while condition is true.

I've added a skip = 1 because we obviously want to skip the composer.json in the box directory (vendor/kerge/box).

tomzx avatar Oct 09 '16 16:10 tomzx

Hi @tomzx, are you using a custom vendor directory location in your composer.json file?

kherge avatar Oct 10 '16 22:10 kherge

@kherge, Nope, just the default vendor folder.

The structure of my project is

composer.json
vendor
- kherge
-- box

I run box using vendor/bin/box on Windows. I think this might be the source of the issue. It appears that under unix variants the box shell script is copied to the vendor/bin folder, while on Windows it simply creates a script that will call the box script from within its folder (so the current working directory is different).

Thus, while realpath($_SERVER['argv'][0]) will return vendor/bin/box under unix variants, it will return vendor/kherge/box/bin/box. Thus, it seems that my fix would most likely break under unix variants.

One suggestion would be to check if the second directory starting from the right is box. Another one would be to have different behavior based on the platform. A third one would be to search for any composer.json that does not contain kherge/box as its name, starting from the current script execution path. There's probably plenty of other ways, although I'm not sure which one is the most appropriate one.

tomzx avatar Oct 11 '16 00:10 tomzx

Fixed in https://github.com/humbug/box/pull/3

theofidry avatar Nov 12 '17 23:11 theofidry