[wp-trac] [WordPress Trac] #47256: Use composer to install and update external PHP libraries
WordPress Trac
noreply at wordpress.org
Tue May 14 17:19:34 UTC 2019
#47256: Use composer to install and update external PHP libraries
-------------------------------------+------------------------------
Reporter: spacedmonkey | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: External Libraries | Version: 5.2
Severity: normal | Resolution:
Keywords: has-patch needs-testing | Focuses:
-------------------------------------+------------------------------
Comment (by giuseppe.mazzapica):
Would not make sense to write a custom installer?
The installer code would be quite simple, according to the current patch,
it could be something around the lines of (**completely untested**):
{{{#!php
<?php
class WordPressLibInstaller extends LibraryInstaller
{
const SRC_BASE = 'src/wp-includes/';
const PACKAGES = [
'paragonie/sodium_compat' => 'sodium_compat',
'paragonie/random_compat' => 'random_compat',
'pomo/pomo' => 'pomo',
'simplepie/simplepie' => 'SimplePie',
'rmccue/requests' => 'Requests',
'pear/text_diff' => 'Text',
'james-heinrich/getid3' => 'ID3',
];
private $vendor;
public function getInstallPath(PackageInterface $package)
{
$name = $package->getPrettyName();
if (empty(self::PACKAGES[$name])) {
return $this->defaultVendor();
}
return self::SRC_BASE . self::PACKAGES[$name] . '/';
}
public function supports($packageType)
{
return $packageType === 'library';
}
public function defaultVendor()
{
if (!$this->vendor) {
$this->vendor = $this->composer->getConfig()
->get('vendor-dir', Config::RELATIVE_PATHS) ?: 'vendor';
}
return $this->vendor;
}
}
}}}
Which has basically the same maintenance burden of the config in the
`installer-paths` array in `composer.json`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/47256#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list