diff --git a/PHPCI/Command/InstallCommand.php b/PHPCI/Command/InstallCommand.php index 3b8ca701..e6432103 100644 --- a/PHPCI/Command/InstallCommand.php +++ b/PHPCI/Command/InstallCommand.php @@ -121,36 +121,26 @@ class InstallCommand extends Command $errors = true; } - // Check for required extensions: - if (!extension_loaded('PDO')) { - $output->writeln(''); - $output->writeln('PDO extension must be installed.'); - $errors = true; + // Check required extensions are present: + $requiredExtensions = array('PDO', 'pdo_mysql', 'mcrypt'); + + foreach ($requiredExtensions as $extension) { + if (!extension_loaded($extension)) { + $output->writeln(''); + $output->writeln(''.$extension.' extension must be installed.'); + $errors = true; + } } - if (!extension_loaded('pdo_mysql')) { - $output->writeln(''); - $output->writeln('PDO MySQL extension must be installed.'); - $errors = true; - } + // Check required functions are callable: + $requiredFunctions = array('exec', 'shell_exec'); - if (!extension_loaded('mcrypt')) { - $output->writeln(''); - $output->writeln('Mcrypt extension must be installed.'); - $errors = true; - } - - // Check we can use the exec() and shell_exec() functions: - if (!function_exists('exec')) { - $output->writeln(''); - $output->writeln('PHPCI needs to be able to call the exec() function. Is it disabled in php.ini?'); - $errors = true; - } - - if (!function_exists('shell_exec')) { - $output->writeln(''); - $output->writeln('PHPCI needs to be able to call the shell_exec() function. Is it disabled in php.ini?'); - $errors = true; + foreach ($requiredFunctions as $function) { + if (!function_exists($function)) { + $output->writeln(''); + $output->writeln('PHPCI needs to be able to call the '.$function.'() function. Is it disabled in php.ini?'); + $errors = true; + } } if (!function_exists('password_hash')) { @@ -160,8 +150,7 @@ class InstallCommand extends Command } if ($errors) { - $output->writeln(''); - die; + throw new Exception('PHPCI cannot be installed, as not all requirements are met. Please review the errors above before continuing.'); } $output->writeln(' OK'); diff --git a/composer.json b/composer.json index 7ccbc600..8de9e9eb 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,10 @@ }, "require": { + "php": ">=5.3.3", + "ext-mcrypt": "*", + "ext-pdo": "*", + "ext-pdo_mysql": "*", "block8/b8framework" : "1.*", "ircmaxell/password-compat": "1.*", "swiftmailer/swiftmailer" : "5.0.*",