Open Konamiman opened 1 year ago
Hi.
Did you get a fix on this or detect what the issue was?
Cheers!
Hi @webcreativeng, I wasn't able to proceed further so I ended up solving the problem I had at hand without using Mozart: https://github.com/woocommerce/woocommerce-bookings/pull/3492
To be fair I'm not sure if I have found a bug or if I'm misunderstanding how Mozart works, but I'm trying to use it to prefix the
google/apiclient
package and so far I'm not succeeding.I have prepared a minimal example. Assume a WordPress plugin named
mozart_test
with the following files to start with:mozart_test.php:
composer.json:
Then I run
composer install
, runwp eval 'mozart_test();
and the the "All good!" message. So far so good.Now, let's introduce Mozart with this updated version of composer.json:
and in the
mozart_test()
function I now try to instantiate a class namedMozartTest\Google\ApiClient
instead.The first issue is that now
composer install
throws this error:This issue goes away and
composer install
succeeds if I add the following toextra/mozart
in composer.json (taken from the configuration for the apiclient package in composer.lock):But now when I try to run the
mozart_test()
function I getPHP Fatal error: Uncaught Error: Class 'MozartTest\Google\Client' not found
. And indeed, if I look at the autoload files invendor/composer
I see no declarations for the Google classes at all (if I don't use Mozart I can see'Google\\' => array($vendorDir . '/google/apiclient/src'),
invendor/composer/autoload_psr4.php
).So my questions would be:
override_autoload
? Isn't Mozart supposed to take the existing configuration from composer.lock by default?Google\Client
class (converted intoMozartTest\Google\Client
) registered by the autoloader? Am I doing something wrong?Another thing I've noticed is that the Google apiclient library has a file named
aliases.php
in which class alias like'Google\\Client' => 'Google_Client'
are declared. These entries get properly renamed by Mozart, but I wonder how this works when there are other WordPress plugins that also use the apiclient package.Thanks for your time!