Recently I came across the followig problem:
Using Composer to manage dependencies for a WordPress plugin, in
particular to include Twig to make it easier to generate the backend UI.
So the code looks similar to this:
<?php
namespace MyPlugin;
use Twig\Loader\FilesystemLoader;
use Twig\Environment;
require(__DIR__ . '/vendor/autoload.php');
...
However - this caused a problem with another plugin which also use Twig
but in a different version. As the other plugin was loaded first the
older version of it was already present. Also having multiple
autoloaders seems not to be a wise idea anyway.
Is there any "best practice" to deal with this or should one just not
try to do such things?
--
Arno Welzel
https://arnowelzel.de
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 475 |
Nodes: | 16 (2 / 14) |
Uptime: | 54:15:14 |
Calls: | 9,496 |
Calls today: | 7 |
Files: | 13,621 |
Messages: | 6,124,209 |
Posted today: | 1 |