puli / issues

The Puli issue tracker.
90 stars 5 forks source link

Composer plugin incompatible with newest composer #190

Closed sagikazarmark closed 8 years ago

sagikazarmark commented 8 years ago

As of https://github.com/composer/composer/commit/fd2f51cea8e5f1ef978cd8f90b87b69dc1778976 composer generates an autoload_static.php file and uses it above php 5.6 instead of the classmap. This makes the generated class unavailable on these platforms.

Unfortunately there is no nice workarounds to this as puli build runs AFTER the autoload files are generated.

If you use symfony, a possible workaround is to add a custom classmap to the autoloader in app/autoload.php:

// Temporary fix for Puli
$loader->addClassMap([
    'Puli\\GeneratedPuliFactory' => __DIR__.'/../.puli/GeneratedPuliFactory.php',
]);
tgalopin commented 8 years ago

There is still a classmap that can be found using a small trick: https://github.com/symfony/symfony/pull/18533/files#diff-ec41b7a9f7c5b4c51f70679eb93504b8R101

However, as I'm not sure what the problem is in the Puli CLI with the newest version, that may not be enough.

sagikazarmark commented 8 years ago

Yeah, that looks pretty good, though does not solve the problem. While in symfony it might (as basically it does something similar to mine hack above), in other applications it will still be an issue above 5.6.

The problem is NOT with the cli, I corrected the issue title, sorry.

The problem is that the composer plugin does not correctly register the generated factory: it is registered in the classmap, more importantly the GENERATED classmap autoloader, which is not used anymore above 5.6.0. Instead the autoload_static.php file is used.

thewilkybarkid commented 8 years ago

I'm looking to see if I can remove the manipulation of the generated Composer autoload files, so that Puli can work no matter what Composer's doing internally.

sagikazarmark commented 8 years ago

Well, it's a composer plugin, so it's purpose is to integrate puli with composer. (But of course Puli works fine without composer as well)

thewilkybarkid commented 8 years ago

Of course, but it would be better to use public APIs as this has shown.

zhangweiquan commented 8 years ago

Hello. Is it possible to install puli/composer-plugin in windows? Because I can't install it in my com. Thanks

helhum commented 8 years ago

I will start looking into that now

helhum commented 8 years ago

@webmozart @thewilkybarkid

https://github.com/puli/composer-plugin/pull/46 looks good ans works well with all composer versions.

I only removed the unnecessary writing of an empty autoload.php in my pull request https://github.com/thewilkybarkid/puli-composer-plugin/pull/2

Other than that, https://github.com/puli/composer-plugin/pull/46 can be merged from my PoV

JLepeltier commented 6 years ago

On your composer file you can do : "autoload": { "classmap": [".puli/"] },