本文整理汇总了PHP中CM_Util::exec方法的典型用法代码示例。如果您正苦于以下问题:PHP CM_Util::exec方法的具体用法?PHP CM_Util::exec怎么用?PHP CM_Util::exec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CM_Util
的用法示例。
在下文中一共展示了CM_Util::exec方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _browserify
/**
* @param string[] $mainPaths
* @param string[] $sourcePaths
* @param bool $generateSourceMaps
* @return string
*/
protected function _browserify(array $mainPaths, array $sourcePaths, $generateSourceMaps)
{
if (!count($mainPaths)) {
return '';
}
$involvedFiles = [];
foreach ($sourcePaths as $sourcePath) {
$involvedFiles = array_merge($involvedFiles, CM_Util::rglob('*.js', $sourcePath));
}
foreach ($mainPaths as $mainPath) {
$involvedFiles[] = $mainPath;
}
$cacheKeyContent = \Functional\reduce_left(array_unique($involvedFiles), function ($path, $index, $collection, $carry) {
return md5($carry . (new CM_File($path))->read());
}, '');
$cacheKeyMainPaths = \Functional\reduce_left($mainPaths, function ($path, $index, $collection, $carry) {
return md5($carry . $path);
}, '');
$cache = CM_Cache_Persistent::getInstance();
$cacheKey = $cache->key(__METHOD__, $cacheKeyContent, $cacheKeyMainPaths, $generateSourceMaps);
return $cache->get($cacheKey, function () use($mainPaths, $sourcePaths, $generateSourceMaps) {
$args = $mainPaths;
if ($generateSourceMaps) {
$args[] = '--debug';
}
return CM_Util::exec('NODE_PATH="' . implode(':', $sourcePaths) . '" browserify', $args);
});
}
示例2: iconRefresh
public function iconRefresh()
{
/** @var CM_File[] $svgFileList */
$svgFileList = array();
foreach (CM_Bootloader::getInstance()->getModules() as $moduleName) {
$iconPath = CM_Util::getModulePath($moduleName) . 'layout/default/resource/img/icon/';
foreach (glob($iconPath . '*.svg') as $svgPath) {
$svgFile = new CM_File($svgPath);
$svgFileList[strtolower($svgFile->getFileName())] = $svgFile;
}
}
if (0 === count($svgFileList)) {
throw new CM_Exception_Invalid('Cannot process `0` icons');
}
$this->_getStreamOutput()->writeln('Processing ' . count($svgFileList) . ' unique icons...');
$dirWork = CM_File::createTmpDir();
$dirBuild = $dirWork->joinPath('/build');
foreach ($svgFileList as $fontFile) {
$fontFile->copyToFile($dirWork->joinPath($fontFile->getFileName()));
}
CM_Util::exec('fontcustom', array('compile', $dirWork->getPathOnLocalFilesystem(), '--no-hash', '--autowidth', '--font-name=icon-webfont', '--output=' . $dirBuild->getPathOnLocalFilesystem()));
$cssFile = $dirBuild->joinPath('/icon-webfont.css');
$less = preg_replace('/url\\("(?:.*?\\/)(.+?)(\\??#.+?)?"\\)/', 'url(urlFont("\\1") + "\\2")', $cssFile->read());
CM_File::create(DIR_PUBLIC . 'static/css/library/icon.less', $less);
foreach (glob($dirBuild->joinPath('/icon-webfont.*')->getPathOnLocalFilesystem()) as $fontPath) {
$fontFile = new CM_File($fontPath);
$fontFile->rename(DIR_PUBLIC . 'static/font/' . $fontFile->getFileName());
}
$dirWork->delete(true);
$this->_getStreamOutput()->writeln('Created web-font and stylesheet.');
}
示例3: _minify
/**
* @param string $content
* @return string
*/
protected function _minify($content)
{
$md5 = md5($content);
$cacheKey = CM_CacheConst::App_Resource . '_md5:' . $md5;
$cache = new CM_Cache_Storage_File();
if (false === ($contentMinified = $cache->get($cacheKey))) {
$uglifyCommand = 'uglifyjs --no-copyright';
/**
* Quote keys in literal objects, otherwise some browsers break.
* E.g. "select2.js" on "Android 4.0.4"
*/
$uglifyCommand .= ' --beautify beautify=false,quote-keys=true';
$contentMinified = CM_Util::exec($uglifyCommand, null, $content);
$cache->set($cacheKey, $contentMinified);
}
return $contentMinified;
}
示例4: _partition
protected function _partition()
{
CM_Util::exec('sgdisk', ['-o', $this->_path]);
$startSector = CM_Util::exec('sgdisk', ['-F', $this->_path]);
$endSector = CM_Util::exec('sgdisk', ['-E', $this->_path]);
CM_Util::exec('sgdisk', ['-n', '1:' . $startSector . ':' . $endSector, $this->_path]);
$this->_path .= '1';
}
示例5: _compileAutoprefixer
/**
* @param string $content
* @return string
*/
private function _compileAutoprefixer($content)
{
$command = 'autoprefixer';
$args = [];
if (null !== $this->_autoprefixerBrowsers) {
$args[] = '--browsers';
$args[] = $this->_autoprefixerBrowsers;
}
return CM_Util::exec($command, $args, $content);
}
示例6: _getChildrenPidList
/**
* @return int[]
* @throws CM_Exception
*/
private function _getChildrenPidList()
{
$psCommand = 'ps axo pid,ppid,args';
$psOutput = CM_Util::exec($psCommand);
if (false === preg_match_all('/^\\s*(?<pid>\\d+)\\s+(?<ppid>\\d+)\\s+(?<args>.+)$/m', $psOutput, $matches, PREG_SET_ORDER)) {
throw new CM_Exception('Cannot parse ps output `' . $psOutput . '`.');
}
$pid = CM_Process::getInstance()->getProcessId();
$pidList = array();
foreach ($matches as $match) {
if ($match['ppid'] == $pid && false === strpos($match['args'], $psCommand)) {
$pidList[] = (int) $match['pid'];
}
}
return $pidList;
}
示例7: getHostId
/**
* @return int
*/
public function getHostId()
{
return (int) hexdec(CM_Util::exec('hostid'));
}
示例8: runDump
/**
* @param string $dbName
* @param CM_File $dump
*/
public static function runDump($dbName, CM_File $dump)
{
$client = CM_Service_Manager::getInstance()->getDatabases()->getMaster();
$args = array();
$args[] = '--host=' . $client->getHost();
$args[] = '--port=' . $client->getPort();
$args[] = '--user=' . $client->getUsername();
$args[] = '--password=' . $client->getPassword();
$args[] = $dbName;
CM_Util::exec('mysql', $args, null, $dump->getPath());
}
示例9: testFreeMemory
public function testFreeMemory()
{
$getMemoryUsage = function () {
$pid = CM_Process::getInstance()->getProcessId();
$memory = CM_Util::exec('ps', ['-o', 'rss', '--no-headers', '--pid', $pid]);
return (int) $memory;
};
$imageOriginal = new CM_File_Image(DIR_TEST_DATA . 'img/test.jpg');
$image = CM_File_Image::createTmp(null, $imageOriginal->read());
$memoryUsage = $getMemoryUsage();
$memoryUsageMaxExpected = $memoryUsage + 20 * 1000;
$image->resizeSpecific(3000, 3000);
$this->assertGreaterThan($memoryUsageMaxExpected, $getMemoryUsage());
$image->freeMemory();
$this->assertLessThan($memoryUsageMaxExpected, $getMemoryUsage());
$image->validateImage();
}