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
I need to prefix the Composer dependencies of a WordPress plugin, I've been studying the differences between Mozart and PHP Scoper and trying to find out what's best for me.
PHP Scoper is a tool focused on Phars, therefore it doesn't seem to be able to handle Composer Autoloader gracefully.
Yoast implementation of PHP-Scoper
Prefixes the vendor libraries, remove them from composer.json and run composer dump-autoload. Then it implements their own spl_autoload_register to autoload the prefixed libraries.
Google Site Kit implementation of PHP-Scoper
Seems to drop Composer Autoloader entirely, implementing their own spl_autoload_register.
I don't like to add spl_autoload_register because it adds a file read for every class lookup, and disks are the slowest thing in computing.
I understand that Mozart is designed to work alongside Composer, using the Composer Autoloader itself. Is that correct?
Would you recommend Mozart or PHP Scoper for prefixing a WordPress plugin? Why? I saw that you (Coen Jacobs) had written an article about this subject on your blog, but the link is dead.
Thanks for your time, for this library, and for sharing your knowledge.
The text was updated successfully, but these errors were encountered:
Obviously, I prefer Mozart for WordPress projects. I know about the other implementations and in #96 (including some more information, which was once published on my now dead blog) I have explained some of the philosophy and choices behind Mozart. Fun fact, PHP-Scoper didn't even exist back when I started Mozart. That obviously doesn't mean that you should or shouldn't use it, but that's one of the main reasons Mozart now exists.
On the topic of autoloading, yes I do believe that Mozart has a unique approach here. Mozart relies on doing as little as possible. In practice, this means that Mozart doesn't change the way Composer is autoloading anything and thus the default autoloader, provided by Composer is used in your project, after Mozart is done transforming the files.
szepeviktor
pushed a commit
to szepeviktor/BrianHenryIE_mozart
that referenced
this issue
Apr 26, 2024
Howdy!
I need to prefix the Composer dependencies of a WordPress plugin, I've been studying the differences between Mozart and PHP Scoper and trying to find out what's best for me.
I see that WooCommerce will be using Mozart on their next releases, while Yoast and Google Site Kit are using PHP Scoper.
PHP Scoper is a tool focused on Phars, therefore it doesn't seem to be able to handle Composer Autoloader gracefully.
Yoast implementation of PHP-Scoper
Prefixes the
vendor
libraries, remove them fromcomposer.json
and runcomposer dump-autoload
. Then it implements their ownspl_autoload_register
to autoload the prefixed libraries.Google Site Kit implementation of PHP-Scoper
Seems to drop Composer Autoloader entirely, implementing their own
spl_autoload_register
.I don't like to add
spl_autoload_register
because it adds a file read for every class lookup, and disks are the slowest thing in computing.I understand that Mozart is designed to work alongside Composer, using the Composer Autoloader itself. Is that correct?
Would you recommend Mozart or PHP Scoper for prefixing a WordPress plugin? Why? I saw that you (Coen Jacobs) had written an article about this subject on your blog, but the link is dead.
Thanks for your time, for this library, and for sharing your knowledge.
The text was updated successfully, but these errors were encountered: