Composer plugin to isolate project dependencies by prefixing their namespace.
- PHP 7.4 or later
- Composer v2
-
It registers itself as a Composer plugin when you add it to your project through the
extra.classdirective in thecomposer.jsonfile pointing toWPElevator\Vendor_Isolator\Pluginin php/class-plugin.php. -
It hooks into
pre-autoload-dumpandpost-autoload-dumpComposer events and uses nikic/php-parser to rewrite the namespaces and classname references for all non-development dependencies. It ignores all global function and classes.
- Describe how this is different from php-scoper and other projects.
-
It only rewrites the non-development dependencies in the
vendordirectory, therefore your application code must reference the isolated dependencies by their prefixed namespace. -
It doesn't replace function definitions and calls in the global namespace. Any definitions and calls to global functions will remain in the global namespace after the transformation.
-
It prefixes the single part imports of dependency namespaces such as
use Nette;so that relative names likeNette\SmartObjectresolve to the prefixed namespace, while imports of global classes such asuse Throwable;are left as is.
A fork of and/composer-isolation.