getExecutable() public static method

public static getExecutable ( $name, boolean $throwException = false ) : boolean | mixed | string
$name
$throwException boolean
return boolean | mixed | string
コード例 #1
0
 /**
  * Install package using 'composer require'.
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int
  * @throws \Exception
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $pidFile = $input->getOption('pid');
     $require = $input->getOption('require');
     try {
         /**
          * TODO consider direct/programmatic usage of composer/composer package
          * @see https://github.com/composer/composer/issues/1906#issuecomment-51632453
          */
         $composerPath = Console::getExecutable('composer');
         if (!$composerPath) {
             $composerPath = Console::getExecutable('composer.phar');
         }
         if (!$composerPath) {
             throw new \Exception('composer executable not found');
         }
         $command = implode(' ', [$composerPath, 'require -d', PIMCORE_DOCUMENT_ROOT, $require, '2>&1']);
         $output->writeln(sprintf("Installing package <b>%s</b>\n", $require));
         $process = new Process($command);
         $process->setTimeout(0);
         $return = $process->run(function ($type, $data) use($output) {
             $output->write($data);
         });
         if ($return !== 0) {
             $this->writeError('Process finished with code: ' . $return);
         } else {
             $output->writeln('<br><b style="color: #0a0;">Package installed successfully.</b>');
         }
     } catch (\Exception $e) {
         $this->writeError($e->getMessage());
     }
     @unlink($pidFile);
 }
コード例 #2
0
ファイル: LibreOffice.php プロジェクト: pimcore/pimcore
 /**
  * @return mixed
  * @throws \Exception
  */
 public static function getLibreOfficeCli()
 {
     return \Pimcore\Tool\Console::getExecutable("soffice", true);
 }
コード例 #3
0
ファイル: Mail.php プロジェクト: pimcore/pimcore
 /**
  * Determines if mbayer html2text is installed (more information at http://www.mbayer.de/html2text/)
  * and uses it to automatically create a text version of the html email
  *
  * @static
  * @return bool
  */
 public static function determineHtml2TextIsInstalled()
 {
     return (bool) \Pimcore\Tool\Console::getExecutable("html2text");
 }
コード例 #4
0
ファイル: AssetController.php プロジェクト: pimcore/pimcore
 public function downloadImageThumbnailAction()
 {
     $image = Asset\Image::getById($this->getParam("id"));
     $config = null;
     if ($this->getParam("config")) {
         $config = \Zend_Json::decode($this->getParam("config"));
     } elseif ($this->getParam("type")) {
         $predefined = ["web" => ["resize_mode" => "scaleByWidth", "width" => 3500, "dpi" => 72, "format" => "JPEG", "quality" => 85], "print" => ["resize_mode" => "scaleByWidth", "width" => 6000, "dpi" => 300, "format" => "JPEG", "quality" => 95], "office" => ["resize_mode" => "scaleByWidth", "width" => 1190, "dpi" => 144, "format" => "JPEG", "quality" => 90]];
         $config = $predefined[$this->getParam("type")];
     }
     if ($config) {
         $thumbnailConfig = new Asset\Image\Thumbnail\Config();
         $thumbnailConfig->setName("pimcore-download-" . $image->getId() . "-" . md5($this->getParam("config")));
         if ($config["resize_mode"] == "scaleByWidth") {
             $thumbnailConfig->addItem("scaleByWidth", ["width" => $config["width"]]);
         } elseif ($config["resize_mode"] == "scaleByHeight") {
             $thumbnailConfig->addItem("scaleByHeight", ["height" => $config["height"]]);
         } else {
             $thumbnailConfig->addItem("resize", ["width" => $config["width"], "height" => $config["height"]]);
         }
         $thumbnailConfig->setQuality($config["quality"]);
         $thumbnailConfig->setFormat($config["format"]);
         if ($thumbnailConfig->getFormat() == "JPEG") {
             $thumbnailConfig->setPreserveMetaData(true);
             $thumbnailConfig->setPreserveColor(true);
         }
         $thumbnail = $image->getThumbnail($thumbnailConfig);
         $thumbnailFile = $thumbnail->getFileSystemPath();
         $exiftool = \Pimcore\Tool\Console::getExecutable("exiftool");
         if ($thumbnailConfig->getFormat() == "JPEG" && $exiftool && isset($config["dpi"]) && $config["dpi"]) {
             \Pimcore\Tool\Console::exec($exiftool . " -overwrite_original -xresolution=" . $config["dpi"] . " -yresolution=" . $config["dpi"] . " -resolutionunit=inches " . escapeshellarg($thumbnailFile));
         }
         $downloadFilename = str_replace("." . File::getFileExtension($image->getFilename()), "." . $thumbnail->getFileExtension(), $image->getFilename());
         $downloadFilename = strtolower($downloadFilename);
         header('Content-Disposition: attachment; filename="' . $downloadFilename . '"');
         header("Content-Type: " . $thumbnail->getMimeType(), true);
         // we have to clear the stat cache here, otherwise filesize() would return the wrong value
         // the reason is that exiftool modifies the file's size, but PHP doesn't know anything about that
         clearstatcache();
         header("Content-Length: " . filesize($thumbnailFile), true);
         $this->sendThumbnailCacheHeaders();
         while (@ob_end_flush()) {
         }
         flush();
         readfile($thumbnailFile);
         @unlink($thumbnailFile);
         exit;
     }
 }
コード例 #5
0
ファイル: Optimizer.php プロジェクト: solverat/pimcore
 public static function optimizeJpegoptim($path)
 {
     $bin = \Pimcore\Tool\Console::getExecutable("jpegoptim");
     if ($bin) {
         $newFile = self::getTempFile("jpg");
         $additionalParams = "";
         if (filesize($path) > 10000) {
             $additionalParams = " --all-progressive";
         }
         $content = Console::exec($bin . $additionalParams . " -o --strip-all --max=85 --stdout " . $path, null, 60);
         if ($content) {
             File::put($newFile, $content);
         }
         return $newFile;
     }
     return null;
 }
コード例 #6
0
ファイル: HtmlToImage.php プロジェクト: solverat/pimcore
 /**
  * @return bool
  */
 public static function getXvfbBinary()
 {
     return \Pimcore\Tool\Console::getExecutable("xvfb-run");
 }
コード例 #7
0
ファイル: Ghostscript.php プロジェクト: pimcore/pimcore
 /**
  * @return mixed
  * @throws \Exception
  */
 public static function getPdftotextCli()
 {
     return \Pimcore\Tool\Console::getExecutable("pdftotext", true);
 }
コード例 #8
0
ファイル: Update.php プロジェクト: solverat/pimcore
 /**
  * @return bool
  */
 public static function isComposerAvailable()
 {
     return (bool) \Pimcore\Tool\Console::getExecutable("composer");
 }
コード例 #9
0
ファイル: ImageMagick.php プロジェクト: pimcore/pimcore
 /**
  * Returns the composite cli script path.
  *
  * @return string
  */
 public function getCompositeScriptPath()
 {
     if (null === $this->compositeScriptPath) {
         $this->compositeScriptPath = Console::getExecutable('composite');
     }
     return $this->compositeScriptPath;
 }
コード例 #10
0
ファイル: CheckController.php プロジェクト: solverat/pimcore
 public function indexAction()
 {
     $checksPHP = [];
     $checksMySQL = [];
     $checksFS = [];
     $checksApps = [];
     // check for memory limit
     $memoryLimit = ini_get("memory_limit");
     $memoryLimit = filesize2bytes($memoryLimit . "B");
     $state = "ok";
     if ($memoryLimit < 67108000) {
         $state = "error";
     } elseif ($memoryLimit < 134217000) {
         $state = "warning";
     }
     $checksPHP[] = ["name" => "memory_limit (in php.ini)", "link" => "http://www.php.net/memory_limit", "state" => $state];
     // pdo_mysql
     $checksPHP[] = ["name" => "PDO_Mysql", "link" => "http://www.php.net/pdo_mysql", "state" => @constant("PDO::MYSQL_ATTR_FOUND_ROWS") ? "ok" : "error"];
     // pdo_mysql
     $checksPHP[] = ["name" => "Mysqli", "link" => "http://www.php.net/mysqli", "state" => class_exists("mysqli") ? "ok" : "error"];
     // iconv
     $checksPHP[] = ["name" => "iconv", "link" => "http://www.php.net/iconv", "state" => function_exists("iconv") ? "ok" : "error"];
     // dom
     $checksPHP[] = ["name" => "dom", "link" => "http://www.php.net/dom", "state" => class_exists("DOMDocument") ? "ok" : "error"];
     // simplexml
     $checksPHP[] = ["name" => "SimpleXML", "link" => "http://www.php.net/simplexml", "state" => class_exists("SimpleXMLElement") ? "ok" : "error"];
     // gd
     $checksPHP[] = ["name" => "GD", "link" => "http://www.php.net/gd", "state" => function_exists("gd_info") ? "ok" : "error"];
     // exif
     $checksPHP[] = ["name" => "EXIF", "link" => "http://www.php.net/exif", "state" => function_exists("exif_read_data") ? "ok" : "error"];
     // multibyte support
     $checksPHP[] = ["name" => "Multibyte String (mbstring)", "link" => "http://www.php.net/mbstring", "state" => function_exists("mb_get_info") ? "ok" : "error"];
     // file_info support
     $checksPHP[] = ["name" => "File Information (file_info)", "link" => "http://www.php.net/file_info", "state" => function_exists("finfo_open") ? "ok" : "error"];
     // zip
     $checksPHP[] = ["name" => "zip", "link" => "http://www.php.net/zip", "state" => class_exists("ZipArchive") ? "ok" : "error"];
     // gzip
     $checksPHP[] = ["name" => "zlib / gzip", "link" => "http://www.php.net/zlib", "state" => function_exists("gzcompress") ? "ok" : "error"];
     // bzip
     $checksPHP[] = ["name" => "Bzip2", "link" => "http://www.php.net/bzip2", "state" => function_exists("bzcompress") ? "ok" : "error"];
     // openssl
     $checksPHP[] = ["name" => "OpenSSL", "link" => "http://www.php.net/openssl", "state" => function_exists("openssl_open") ? "ok" : "error"];
     // Imagick
     $checksPHP[] = ["name" => "Imagick", "link" => "http://www.php.net/imagick", "state" => class_exists("Imagick") ? "ok" : "warning"];
     // OPcache
     $checksPHP[] = ["name" => "OPcache", "link" => "http://www.php.net/opcache", "state" => function_exists("opcache_reset") ? "ok" : "warning"];
     // memcache
     $checksPHP[] = ["name" => "Memcache", "link" => "http://www.php.net/memcache", "state" => class_exists("Memcache") ? "ok" : "warning"];
     // Redis
     $checksPHP[] = ["name" => "Redis", "link" => "https://pecl.php.net/package/redis", "state" => class_exists("Redis") ? "ok" : "warning"];
     // curl for google api sdk
     $checksPHP[] = ["name" => "curl", "link" => "http://www.php.net/curl", "state" => function_exists("curl_init") ? "ok" : "warning"];
     $db = null;
     if ($this->getParam("mysql_adapter")) {
         // this is before installing
         try {
             $dbConfig = ['username' => $this->getParam("mysql_username"), 'password' => $this->getParam("mysql_password"), 'dbname' => $this->getParam("mysql_database")];
             $hostSocketValue = $this->getParam("mysql_host_socket");
             if (file_exists($hostSocketValue)) {
                 $dbConfig["unix_socket"] = $hostSocketValue;
             } else {
                 $dbConfig["host"] = $hostSocketValue;
                 $dbConfig["port"] = $this->getParam("mysql_port");
             }
             $db = \Zend_Db::factory($this->getParam("mysql_adapter"), $dbConfig);
             $db->getConnection();
         } catch (\Exception $e) {
             $db = null;
         }
     } else {
         // this is after installing, eg. after a migration, ...
         $db = \Pimcore\Db::get();
     }
     if ($db) {
         // storage engines
         $engines = [];
         $enginesRaw = $db->fetchAll("SHOW ENGINES;");
         foreach ($enginesRaw as $engineRaw) {
             $engines[] = strtolower($engineRaw["Engine"]);
         }
         // innodb
         $checksMySQL[] = ["name" => "InnoDB Support", "state" => in_array("innodb", $engines) ? "ok" : "error"];
         // myisam
         $checksMySQL[] = ["name" => "MyISAM Support", "state" => in_array("myisam", $engines) ? "ok" : "error"];
         // memory
         $checksMySQL[] = ["name" => "MEMORY Support", "state" => in_array("memory", $engines) ? "ok" : "error"];
         // check database charset =>  utf-8 encoding
         $result = $db->fetchRow('SHOW VARIABLES LIKE "character\\_set\\_database"');
         $checksMySQL[] = ["name" => "Database Charset UTF8", "state" => in_array($result['Value'], ["utf8", "utf8mb4"]) ? "ok" : "error"];
         // create table
         $queryCheck = true;
         try {
             $db->query("CREATE TABLE __pimcore_req_check (\n                  id int(11) NOT NULL AUTO_INCREMENT,\n                  field varchar(255) CHARACTER SET latin1 NULL DEFAULT NULL,\n                  PRIMARY KEY (id)\n                ) DEFAULT CHARSET=utf8 COLLATE utf8_general_ci");
         } catch (\Exception $e) {
             $queryCheck = false;
         }
         $checksMySQL[] = ["name" => "CREATE TABLE", "state" => $queryCheck ? "ok" : "error"];
         // alter table
         $queryCheck = true;
         try {
             $db->query("ALTER TABLE __pimcore_req_check ADD COLUMN alter_field varchar(255) NULL DEFAULT NULL");
         } catch (\Exception $e) {
             $queryCheck = false;
         }
         $checksMySQL[] = ["name" => "ALTER TABLE", "state" => $queryCheck ? "ok" : "error"];
         // Manage indexes
         $queryCheck = true;
         try {
             $db->query("ALTER TABLE __pimcore_req_check\n                  CHANGE COLUMN id id int(11) NOT NULL,\n                  CHANGE COLUMN field field varchar(255) NULL DEFAULT NULL,\n                  CHANGE COLUMN alter_field alter_field varchar(255) NULL DEFAULT NULL,\n                  ADD KEY field (field),\n                  DROP PRIMARY KEY ,\n                 DEFAULT CHARSET=utf8");
             $db->query("ALTER TABLE __pimcore_req_check\n                  CHANGE COLUMN id id int(11) NOT NULL AUTO_INCREMENT,\n                  CHANGE COLUMN field field varchar(255) NULL DEFAULT NULL,\n                  CHANGE COLUMN alter_field alter_field varchar(255) NULL DEFAULT NULL,\n                  ADD PRIMARY KEY (id) ,\n                 DEFAULT CHARSET=utf8");
         } catch (\Exception $e) {
             $queryCheck = false;
         }
         $checksMySQL[] = ["name" => "Manage Indexes", "state" => $queryCheck ? "ok" : "error"];
         // insert data
         $queryCheck = true;
         try {
             $db->insert("__pimcore_req_check", ["field" => uniqid(), "alter_field" => uniqid()]);
         } catch (\Exception $e) {
             $queryCheck = false;
         }
         $checksMySQL[] = ["name" => "INSERT", "state" => $queryCheck ? "ok" : "error"];
         // update
         $queryCheck = true;
         try {
             $db->update("__pimcore_req_check", ["field" => uniqid(), "alter_field" => uniqid()]);
         } catch (\Exception $e) {
             $queryCheck = false;
         }
         $checksMySQL[] = ["name" => "UPDATE", "state" => $queryCheck ? "ok" : "error"];
         // select
         $queryCheck = true;
         try {
             $db->fetchAll("SELECT * FROM __pimcore_req_check");
         } catch (\Exception $e) {
             $queryCheck = false;
         }
         $checksMySQL[] = ["name" => "SELECT", "state" => $queryCheck ? "ok" : "error"];
         // create view
         $queryCheck = true;
         try {
             $db->query("CREATE OR REPLACE VIEW __pimcore_req_check_view AS SELECT * FROM __pimcore_req_check");
         } catch (\Exception $e) {
             $queryCheck = false;
         }
         $checksMySQL[] = ["name" => "CREATE VIEW", "state" => $queryCheck ? "ok" : "error"];
         // select from view
         $queryCheck = true;
         try {
             $db->fetchAll("SELECT * FROM __pimcore_req_check_view");
         } catch (\Exception $e) {
             $queryCheck = false;
         }
         $checksMySQL[] = ["name" => "SELECT (from view)", "state" => $queryCheck ? "ok" : "error"];
         // delete
         $queryCheck = true;
         try {
             $db->delete("__pimcore_req_check");
         } catch (\Exception $e) {
             $queryCheck = false;
         }
         $checksMySQL[] = ["name" => "DELETE", "state" => $queryCheck ? "ok" : "error"];
         // show create view
         $queryCheck = true;
         try {
             $db->query("SHOW CREATE VIEW __pimcore_req_check_view");
         } catch (\Exception $e) {
             $queryCheck = false;
         }
         $checksMySQL[] = ["name" => "SHOW CREATE VIEW", "state" => $queryCheck ? "ok" : "error"];
         // show create table
         $queryCheck = true;
         try {
             $db->query("SHOW CREATE TABLE __pimcore_req_check");
         } catch (\Exception $e) {
             $queryCheck = false;
         }
         $checksMySQL[] = ["name" => "SHOW CREATE TABLE", "state" => $queryCheck ? "ok" : "error"];
         // drop view
         $queryCheck = true;
         try {
             $db->query("DROP VIEW __pimcore_req_check_view");
         } catch (\Exception $e) {
             $queryCheck = false;
         }
         $checksMySQL[] = ["name" => "DROP VIEW", "state" => $queryCheck ? "ok" : "error"];
         // drop table
         $queryCheck = true;
         try {
             $db->query("DROP TABLE __pimcore_req_check");
         } catch (\Exception $e) {
             $queryCheck = false;
         }
         $checksMySQL[] = ["name" => "DROP TABLE", "state" => $queryCheck ? "ok" : "error"];
     } else {
         die("Not possible... no or wrong database settings given.<br />Please fill out the MySQL Settings in the install form an click again on `Check Requirements´");
     }
     // filesystem checks
     // website/var writable
     $websiteVarWritable = true;
     try {
         $files = $this->rscandir(PIMCORE_WEBSITE_VAR);
         foreach ($files as $file) {
             if (!is_writable($file)) {
                 $websiteVarWritable = false;
             }
         }
         $checksFS[] = ["name" => "/website/var/ writeable", "state" => $websiteVarWritable ? "ok" : "error"];
     } catch (\Exception $e) {
         $checksFS[] = ["name" => "/website/var/ (not checked - too many files)", "state" => "warning"];
     }
     // pimcore writeable
     $checksFS[] = ["name" => "/pimcore/ writeable", "state" => \Pimcore\Update::isWriteable() ? "ok" : "warning"];
     // system & application checks
     // PHP CLI BIN
     try {
         $phpCliBin = (bool) \Pimcore\Tool\Console::getPhpCli();
     } catch (\Exception $e) {
         $phpCliBin = false;
     }
     $checksApps[] = ["name" => "PHP", "state" => $phpCliBin ? "ok" : "error"];
     // Composer
     $checksApps[] = ["name" => "Composer", "state" => Update::isComposerAvailable() ? "ok" : "error"];
     // FFMPEG BIN
     try {
         $ffmpegBin = (bool) \Pimcore\Video\Adapter\Ffmpeg::getFfmpegCli();
     } catch (\Exception $e) {
         $ffmpegBin = false;
     }
     $checksApps[] = ["name" => "FFMPEG", "state" => $ffmpegBin ? "ok" : "warning"];
     // WKHTMLTOIMAGE BIN
     try {
         $wkhtmltopdfBin = (bool) \Pimcore\Image\HtmlToImage::getWkhtmltoimageBinary();
     } catch (\Exception $e) {
         $wkhtmltopdfBin = false;
     }
     $checksApps[] = ["name" => "wkhtmltoimage", "state" => $wkhtmltopdfBin ? "ok" : "warning"];
     // HTML2TEXT BIN
     try {
         $html2textBin = (bool) \Pimcore\Mail::determineHtml2TextIsInstalled();
     } catch (\Exception $e) {
         $html2textBin = false;
     }
     $checksApps[] = ["name" => "html2text (mbayer)", "state" => $html2textBin ? "ok" : "warning"];
     // ghostscript BIN
     try {
         $ghostscriptBin = (bool) \Pimcore\Document\Adapter\Ghostscript::getGhostscriptCli();
     } catch (\Exception $e) {
         $ghostscriptBin = false;
     }
     $checksApps[] = ["name" => "Ghostscript", "state" => $ghostscriptBin ? "ok" : "warning"];
     // LibreOffice BIN
     try {
         $libreofficeBin = (bool) \Pimcore\Document\Adapter\LibreOffice::getLibreOfficeCli();
     } catch (\Exception $e) {
         $libreofficeBin = false;
     }
     $checksApps[] = ["name" => "LibreOffice", "state" => $libreofficeBin ? "ok" : "warning"];
     // image optimizer
     foreach (["zopflipng", "pngcrush", "jpegoptim", "imgmin", "pngout", "advpng", "cjpeg"] as $optimizerName) {
         try {
             $optimizerAvailable = \Pimcore\Tool\Console::getExecutable($optimizerName);
         } catch (\Exception $e) {
             $optimizerAvailable = false;
         }
         $checksApps[] = ["name" => $optimizerName, "state" => $optimizerAvailable ? "ok" : "warning"];
     }
     // timeout binary
     try {
         $timeoutBin = (bool) \Pimcore\Tool\Console::getTimeoutBinary();
     } catch (\Exception $e) {
         $timeoutBin = false;
     }
     $checksApps[] = ["name" => "timeout - (GNU coreutils)", "state" => $timeoutBin ? "ok" : "warning"];
     // pdftotext binary
     try {
         $pdftotextBin = (bool) \Pimcore\Document\Adapter\Ghostscript::getPdftotextCli();
     } catch (\Exception $e) {
         $pdftotextBin = false;
     }
     $checksApps[] = ["name" => "pdftotext - (part of poppler-utils)", "state" => $pdftotextBin ? "ok" : "warning"];
     $this->view->checksApps = $checksApps;
     $this->view->checksPHP = $checksPHP;
     $this->view->checksMySQL = $checksMySQL;
     $this->view->checksFS = $checksFS;
 }
コード例 #11
0
ファイル: Ffmpeg.php プロジェクト: pimcore/pimcore
 /**
  * @return mixed
  * @throws \Exception
  */
 public static function getFfmpegCli()
 {
     return \Pimcore\Tool\Console::getExecutable("ffmpeg", true);
 }