{
use CliCommand;
+ /**
+ * Cleanups
+ * @var array
+ */
+ private $cleanup = [];
+
/**
* Create the command
*/
]);
}
- private function extract(Phar $phar) {
- $this->debug("Extracting %s ...\n", basename($phar->getPath()));
- return (new Task\Extract($phar))->run($this->verbosity());
+ /**
+ * Perform cleaniup
+ */
+ function __destruct() {
+ foreach ($this->cleanup as $cleanup) {
+ $cleanup->run();
+ }
+ }
+
+ private function extract($phar) {
+ $temp = (new Task\Extract($phar))->run($this->verbosity());
+ $this->cleanup[] = new Task\Cleanup($temp);
+ return $temp;
}
private function hooks(SplObjectStorage $phars) {
private function load() {
$list = new SplObjectStorage();
- $phar = new Phar(Phar::running(false));
+ $phar = extension_loaded("Phar")
+ ? new Phar(Phar::running(false))
+ : new Archive(PHAREXT_PHAR);
$temp = $this->extract($phar);
foreach ($phar as $entry) {
$dep_file = $entry->getBaseName();
if (fnmatch("*.ext.phar*", $dep_file)) {
- $dep_phar = new Phar("$temp/$dep_file");
+ $dep_phar = extension_loaded("Phar")
+ ? new Phar("$temp/$dep_file")
+ : new Archive("$temp/$dep_file");
$list[$dep_phar] = $this->extract($dep_phar);
}
}
$this->info("Installing %s ...\n", basename($phar->getPath()));
$this->install($list[$phar]);
$this->activate($list[$phar]);
- $this->cleanup($list[$phar]);
$this->info("Successfully installed %s!\n", basename($phar->getPath()));
}
} catch (\Exception $e) {
*/
private function install($temp) {
// phpize
- $this->info("Running phpize ...\n");
$phpize = new Task\Phpize($temp, $this->args->prefix, $this->args->{"common-name"});
$phpize->run($this->verbosity());
// configure
- $this->info("Running configure ...\n");
$configure = new Task\Configure($temp, $this->args->configure, $this->args->prefix, $this->args{"common-name"});
$configure->run($this->verbosity());
// make
- $this->info("Running make ...\n");
$make = new Task\Make($temp);
$make->run($this->verbosity());
// install
- $this->info("Running make install ...\n");
$sudo = isset($this->args->sudo) ? $this->args->sudo : null;
$install = new Task\Make($temp, ["install"], $sudo);
$install->run($this->verbosity());
}
- private function cleanup($temp) {
- (new Task\Cleanup($temp))->run();
- }
-
private function activate($temp) {
if ($this->args->ini) {
- $files = [realpath($this->args->ini)];
+ $files = [$this->args->ini];
} else {
$files = array_filter(array_map("trim", explode(",", php_ini_scanned_files())));
$files[] = php_ini_loaded_file();
$sudo = isset($this->args->sudo) ? $this->args->sudo : null;
$type = $this->metadata("type") ?: "extension";
- $this->info("Running INI activation ...\n");
$activate = new Task\Activate($temp, $files, $type, $this->args->prefix, $this->args{"common-name"}, $sudo);
if (!$activate->run($this->verbosity())) {
$this->info("Extension already activated ...\n");