Add command to dump required PHP extensions based on vendor/composer/… (#599)

* Add command to dump required PHP extensions based on vendor/composer/installed.json, composer.lock, composer.json (in this order)

* remove unused use

* missing translation

* Adjust dump-extensions

* Add docs for dump-extension command

---------

Co-authored-by: crazywhalecc <jesse2061@outlook.com>
This commit is contained in:
Alexander Over
2025-03-07 03:46:07 +01:00
committed by GitHub
parent 34934368a2
commit 6b227d88ac
6 changed files with 220 additions and 5 deletions

View File

@@ -154,24 +154,24 @@ abstract class BaseCommand extends Command
/**
* Parse extension list from string, replace alias and filter internal extensions.
*
* @param string $ext_list Extension string list, e.g. "mbstring,posix,sockets"
* @param array|string $ext_list Extension string list, e.g. "mbstring,posix,sockets" or array
*/
protected function parseExtensionList(string $ext_list): array
protected function parseExtensionList(array|string $ext_list): array
{
// replace alias
$ls = array_map(function ($x) {
$lower = strtolower(trim($x));
if (isset(SPC_EXTENSION_ALIAS[$lower])) {
logger()->notice("Extension [{$lower}] is an alias of [" . SPC_EXTENSION_ALIAS[$lower] . '], it will be replaced.');
logger()->debug("Extension [{$lower}] is an alias of [" . SPC_EXTENSION_ALIAS[$lower] . '], it will be replaced.');
return SPC_EXTENSION_ALIAS[$lower];
}
return $lower;
}, explode(',', $ext_list));
}, is_array($ext_list) ? $ext_list : explode(',', $ext_list));
// filter internals
return array_values(array_filter($ls, function ($x) {
if (in_array($x, SPC_INTERNAL_EXTENSIONS)) {
logger()->warning("Extension [{$x}] is an builtin extension, it will be ignored.");
logger()->debug("Extension [{$x}] is an builtin extension, it will be ignored.");
return false;
}
return true;