You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
and in the mozart_test() function I now try to instantiate a class named MozartTest\Google\ApiClient instead.
The first issue is that now composer install throws this error:
In Finder.php line 592:
The "/home/konamiman/wordpress/wp-content/plugins/mozart_test/vendor_src/psr0//google/apiclient" directory does not exist.
This issue goes away and composer install succeeds if I add the following to extra/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 get PHP Fatal error: Uncaught Error: Class 'MozartTest\Google\Client' not found. And indeed, if I look at the autoload files in vendor/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'), in vendor/composer/autoload_psr4.php).
So my questions would be:
Why do I need to add the extra configuration in override_autoload? Isn't Mozart supposed to take the existing configuration from composer.lock by default?
Why isn't the Google\Client class (converted into MozartTest\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!
The text was updated successfully, but these errors were encountered:
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!
The text was updated successfully, but these errors were encountered: