add composer extensions check & function_exists checks

This commit is contained in:
Thomas Citharel 2016-02-23 19:06:37 +01:00
parent fc6020b2c8
commit db847ca0b7
2 changed files with 40 additions and 8 deletions

View File

@ -66,7 +66,23 @@
"paragonie/random_compat": "~1.0", "paragonie/random_compat": "~1.0",
"craue/config-bundle": "~1.4", "craue/config-bundle": "~1.4",
"mnapoli/piwik-twig-extension": "^1.0", "mnapoli/piwik-twig-extension": "^1.0",
"lexik/maintenance-bundle": "~2.1" "lexik/maintenance-bundle": "~2.1",
"ext-pcre": "*",
"ext-DOM": "*",
"ext-curl": "*",
"ext-gd": "*",
"ext-session": "*",
"ext-Ctype": "*",
"ext-hash": "*",
"ext-simplexml": "*",
"ext-json": "*",
"ext-mbstring": "*",
"ext-xml": "*",
"ext-tidy": "*",
"ext-iconv": "*",
"ext-gettext": "*",
"ext-tokenizer": "*",
"ext-PDO": "*"
}, },
"require-dev": { "require-dev": {
"doctrine/doctrine-fixtures-bundle": "~2.2", "doctrine/doctrine-fixtures-bundle": "~2.2",

View File

@ -29,9 +29,11 @@ class InstallCommand extends ContainerAwareCommand
/** /**
* @var array * @var array
*/ */
protected $requirements = [ protected $functionExists = [
'pcre', 'tidy_parse_string',
'DOM', 'curl_exec',
'curl_multi_init',
'gettext',
]; ];
protected function configure() protected function configure()
@ -73,16 +75,30 @@ class InstallCommand extends ContainerAwareCommand
$fulfilled = true; $fulfilled = true;
foreach ($this->requirements as $requirement) { $label = '<comment>PDO Drivers</comment>';
$label = '<comment>'.strtoupper($requirement).'</comment>'; if (extension_loaded('pdo_sqlite') || extension_loaded('pdo_mysql') || extension_loaded('pdo_pgsql')) {
if (extension_loaded($requirement)) { $status = '<info>OK!</info>';
$help = '';
} else {
$fulfilled = false;
$status = '<error>ERROR!</error>';
$help = 'Needs one of sqlite, mysql or pgsql PDO drivers';
}
$rows[] = array($label, $status, $help);
foreach ($this->functionExists as $functionRequired) {
$label = '<comment>'.$functionRequired.'</comment>';
if (function_exists($functionRequired)) {
$status = '<info>OK!</info>'; $status = '<info>OK!</info>';
$help = ''; $help = '';
} else { } else {
$fulfilled = false; $fulfilled = false;
$status = '<error>ERROR!</error>'; $status = '<error>ERROR!</error>';
$help = 'You should enabled '.$requirement.' extension'; $help = 'You need the '.$requirement.' function activated';
} }
$rows[] = array($label, $status, $help); $rows[] = array($label, $status, $help);
} }