When I run any composer command I get this error:
PHP Fatal error: Uncaught Error: Undefined class constant 'PRE_COMMAND_RUN' in /var/www/drug-mart.ca/vendor/laminas/laminas-dependency-plugin/src/DependencyRewriterPlugin.php:63
Stack trace:
#0 /usr/share/php/Composer/EventDispatcher/EventDispatcher.php(378): Laminas\DependencyPlugin\DependencyRewriterPlugin::getSubscribedEvents()
#1 /usr/share/php/Composer/Plugin/PluginManager.php(239): Composer\EventDispatcher\EventDispatcher->addSubscriber(Object(Laminas\DependencyPlugin\DependencyRewriterPlugin))
#2 /usr/share/php/Composer/Plugin/PluginManager.php(205): Composer\Plugin\PluginManager->addPlugin(Object(Laminas\DependencyPlugin\DependencyRewriterPlugin))
#3 /usr/share/php/Composer/Plugin/PluginManager.php(261): Composer\Plugin\PluginManager->registerPackage(Object(Composer\Package\CompletePackage))
#4 /usr/share/php/Composer/Plugin/PluginManager.php(76): Composer\Plugin\PluginManager->loadRepository(Object(Composer\Repository\InstalledFilesystemRepository))
#5 /usr/share/php/Composer/Factory.php(384): Composer\Plugin\PluginM in /var/www/drug-mart.ca/vendor/laminas/laminas-dependency-plugin/src/DependencyRewriterPlugin.php on line 63
Fatal error: Uncaught Error: Undefined class constant 'PRE_COMMAND_RUN' in /var/www/drug-mart.ca/vendor/laminas/laminas-dependency-plugin/src/DependencyRewriterPlugin.php:63
Stack trace:
#0 /usr/share/php/Composer/EventDispatcher/EventDispatcher.php(378): Laminas\DependencyPlugin\DependencyRewriterPlugin::getSubscribedEvents()
#1 /usr/share/php/Composer/Plugin/PluginManager.php(239): Composer\EventDispatcher\EventDispatcher->addSubscriber(Object(Laminas\DependencyPlugin\DependencyRewriterPlugin))
#2 /usr/share/php/Composer/Plugin/PluginManager.php(205): Composer\Plugin\PluginManager->addPlugin(Object(Laminas\DependencyPlugin\DependencyRewriterPlugin))
#3 /usr/share/php/Composer/Plugin/PluginManager.php(261): Composer\Plugin\PluginManager->registerPackage(Object(Composer\Package\CompletePackage))
#4 /usr/share/php/Composer/Plugin/PluginManager.php(76): Composer\Plugin\PluginManager->loadRepository(Object(Composer\Repository\InstalledFilesystemRepository))
#5 /usr/share/php/Composer/Factory.php(384): Composer\Plugin\PluginM in /var/www/drug-mart.ca/vendor/laminas/laminas-dependency-plugin/src/DependencyRewriterPlugin.php on line 63
Please HELP!
Solved! Go to Solution.
Needed to reinstall composer from version 1.6 to 1.10
I'd be glad to help you with the Composer error "Undefined class constant 'PRE_COMMAND_RUN'".
Understanding the Error:
This error indicates that the laminas/laminas-dependency-plugin library you're using is referencing a constant named PRE_COMMAND_RUN which isn't defined in your current Composer version. This constant was likely introduced in a newer version of Composer.
Potential Causes:
Solutions:
Upgrade Composer:
composer self-update
Clear Composer Cache:
composer clearcache
Check Plugin Version:
Additional Tips:
If the issue persists after trying these solutions, provide more details:
By following these steps and providing additional information if needed, you should be able to resolve the Composer error and run your drugtests composer commands successfully.