php - Autoloading two vendor projects with composer at the same time -
i've 2 projects (project1, project2) composer set correctly, own composer.json
{ "require": { "wp-cli/wp-cli": "0.15.1" } }
now, in php file autoload them via
require_once 'project1/vendor/autoload.php'; require_once 'project2/vendor/autoload.php';
and error
fatal error: cannot redeclare cli\render() (previously declared in /private/tmp/php/project1/vendor/wp-cli/php-cli-tools/lib/cli/cli.php:26) in /private/tmp/php/project2/vendor/wp-cli/php-cli-tools/lib/cli/cli.php on line 28
is problem of wp-cli or issue composer? i've tried library such monolog fine.
any idea?
you shouldn't use composer autoloader twice.
there simple solution: in third project, create new composer.json
, include 2 other projects there.
then include autoloading of third project. there no duplicate classes involved. should work if configured correct autoloading not libraries use in of 2 projects, classes in these projects.
Comments
Post a Comment