本文整理汇总了PHP中pake_echo_action函数的典型用法代码示例。如果您正苦于以下问题:PHP pake_echo_action函数的具体用法?PHP pake_echo_action怎么用?PHP pake_echo_action使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pake_echo_action函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install_pear_package
public static function install_pear_package($package, $channel = 'pear.php.net')
{
if (!class_exists('PEAR_Config')) {
@(include 'PEAR/Registry.php');
// loads config, among other things
if (!class_exists('PEAR_Config')) {
throw new pakeException('PEAR subsystem is unavailable (not in include_path?)');
}
}
$cfg = PEAR_Config::singleton();
$registry = $cfg->getRegistry();
// 1. check if package is installed
if ($registry->_packageExists($package, $channel)) {
return true;
}
$need_sudo = (!is_writable($cfg->get('download_dir')) or !is_writable($cfg->get('php_dir')));
// 2. if not installed, discover channel
if (!$registry->_channelExists($channel, true)) {
// sudo discover channel
pake_echo_action('pear', 'discovering channel ' . $channel);
if ($need_sudo) {
pake_superuser_sh('pear channel-discover ' . escapeshellarg($channel));
} else {
$this->nativePearDiscover($channel);
}
}
// 3. install package
pake_echo_action('pear', 'installing ' . $channel . '/' . $package);
if ($need_sudo) {
pake_superuser_sh('pear install ' . escapeshellarg($channel . '/' . $package), true);
} else {
$this->nativePearInstall($package, $channel);
}
}
示例2: run_freeze
function run_freeze($task, $args)
{
// check that the symfony librairies are not already freeze for this project
if (is_readable(sfConfig::get('sf_lib_dir') . '/symfony')) {
throw new Exception('You can only freeze when lib/symfony is empty.');
}
if (is_readable(sfConfig::get('sf_data_dir') . '/symfony')) {
throw new Exception('You can only freeze when data/symfony is empty.');
}
if (is_readable(sfConfig::get('sf_web_dir') . '/sf')) {
throw new Exception('You can only freeze when web/sf is empty.');
}
if (is_link(sfConfig::get('sf_web_dir') . '/sf')) {
pake_remove(sfConfig::get('sf_web_dir') . '/sf', '');
}
$symfony_lib_dir = sfConfig::get('sf_symfony_lib_dir');
$symfony_data_dir = sfConfig::get('sf_symfony_data_dir');
pake_echo_action('freeze', 'freezing lib found in "' . $symfony_lib_dir . '"');
pake_echo_action('freeze', 'freezing data found in "' . $symfony_data_dir . '"');
pake_mkdirs(sfConfig::get('sf_lib_dir') . DIRECTORY_SEPARATOR . 'symfony');
pake_mkdirs(sfConfig::get('sf_data_dir') . DIRECTORY_SEPARATOR . 'symfony');
$finder = pakeFinder::type('any')->ignore_version_control();
pake_mirror($finder, $symfony_lib_dir, sfConfig::get('sf_lib_dir') . '/symfony');
pake_mirror($finder, $symfony_data_dir, sfConfig::get('sf_data_dir') . '/symfony');
pake_rename(sfConfig::get('sf_data_dir') . '/symfony/web/sf', sfConfig::get('sf_web_dir') . '/sf');
// change symfony paths in config/config.php
file_put_contents('config/config.php.bak', "{$symfony_lib_dir}#{$symfony_data_dir}");
_change_symfony_dirs("dirname(__FILE__).'/../lib/symfony'", "dirname(__FILE__).'/../data/symfony'");
// install the command line
pake_copy($symfony_data_dir . '/bin/symfony.php', 'symfony.php');
}
示例3: run_tar
function run_tar($task, $args)
{
run_freeze($task, $args);
pake_echo_action('tar', 'Making a tarball');
exec('PROJ=`pwd | awk \'BEGIN {FS="/"} {print $NF}\'`;cd ..; tar -czf $PROJ.tgz $PROJ --exclude=.svn --exclude=$PROJ/.* --exclude=$PROJ/log/* --exclude=$PROJ/cache/* ; cd $PROJ');
run_unfreeze($task, $args);
}
示例4: run_disallow_permissions
function run_disallow_permissions()
{
$settings = getSettings();
$root = "..";
pake_echo_action("permissions", "allow permissions...");
pake_chmod('', $root, 0755);
}
示例5: emitFile
public static function emitFile($data, $file)
{
if (file_exists($file) and !is_writable($file)) {
throw new pakeException('Not enough rights to overwrite "' . $file . '"');
}
$dir = dirname($file);
pake_mkdirs($dir);
if (!is_writable($dir)) {
throw new pakeException('Not enough rights to create file in "' . $dir . '"');
}
if (extension_loaded('yaml')) {
// not yet implemented:
// yaml_emit_file($file, $data);
// so using this instead:
if (false === file_put_contents($file, yaml_emit($data))) {
throw new pakeException("Couldn't create file");
}
} else {
sfYaml::setSpecVersion('1.1');
// more compatible
$dumper = new sfYamlDumper();
if (false === file_put_contents($file, $dumper->dump($data, 1))) {
throw new pakeException("Couldn't create file");
}
}
pake_echo_action('file+', $file);
}
示例6: run_propel_insert_sql_diff
function run_propel_insert_sql_diff($task, $args)
{
run_propel_build_sql_diff($task, $args);
$filename = sfConfig::get('sf_data_dir') . '/sql/diff.sql';
pake_echo_action('propel-sql-diff', "executing file {$filename}");
$i = new dbInfo();
$i->executeSql(file_get_contents($filename));
}
示例7: export
public static function export($src_url, $target_path)
{
if (count(pakeFinder::type('any')->in($target_path)) > 0) {
throw new pakeException('"' . $target_path . '" directory is not empty. Can not export there');
}
pake_echo_action('svn export', $target_path);
if (extension_loaded('svn')) {
$result = svn_export($src_url, $target_path, false);
if (false === $result) {
throw new pakeException('Couldn\'t export "' . $src_url . '" repository');
}
} else {
pake_sh(escapeshellarg(pake_which('svn')) . ' export ' . escapeshellarg($src_url) . ' ' . escapeshellarg($target_path));
}
}
示例8: run_compact
/**
* To be able to include a plugin in pake_runtime.php, you have to use include_once for external dependencies
* and require_once for internal dependencies (for other included PI or pake classes) because we strip
* all require_once statements
*/
function run_compact($task, $args)
{
$_root = dirname(__FILE__);
$options = pakeYaml::loadFile($_root . '/options.yaml');
$version = $options['version'];
pake_replace_tokens('lib/pake/pakeApp.class.php', $_root, 'const VERSION = \'', '\';', array('1.1.DEV' => "const VERSION = '{$version}';"));
// core-files
$files = array($_root . '/lib/pake/init.php', $_root . '/lib/pake/pakeFunction.php');
// adding pake-classes library
$files = array_merge($files, pakeFinder::type('file')->name('*.class.php')->maxdepth(0)->in($_root . '/lib/pake'));
// adding sfYaml library
$files = array_merge($files, pakeFinder::type('file')->name('*.php')->in($_root . '/lib/pake/sfYaml'));
$plugins = $args;
foreach ($plugins as $plugin_name) {
$files[] = $_root . '/lib/pake/tasks/pake' . $plugin_name . 'Task.class.php';
}
// starter
$files[] = $_root . '/bin/pake.php';
// merge all files
$content = '';
foreach ($files as $file) {
$content .= file_get_contents($file);
}
pake_replace_tokens('lib/pake/pakeApp.class.php', $_root, "const VERSION = '", "';", array($version => "const VERSION = '1.1.DEV';"));
// strip require_once statements
$content = preg_replace('/^\\s*require(?:_once)?[^$;]+;/m', '', $content);
// replace windows and mac format with unix format
$content = str_replace(array("\r\n"), "\n", $content);
// strip php tags
$content = preg_replace(array("/<\\?php/", "/<\\?/", "/\\?>/"), '', $content);
// replace multiple new lines with a single newline
$content = preg_replace(array("/\n\\s+\n/s", "/\n+/s"), "\n", $content);
$content = "#!/usr/bin/env php\n<?php\n" . trim($content) . "\n";
$target_dir = $_root . '/target';
pake_mkdirs($target_dir);
$target = $target_dir . '/pake';
if (!file_put_contents($target, $content)) {
throw new pakeException('Failed to write to "' . $target . '"');
}
pake_echo_action('file+', $target);
// strip all comments
pake_strip_php_comments($target);
pake_chmod('pake', $target_dir, 0755);
}
示例9: sqlExec
private function sqlExec($sql)
{
if ($this->mode == 'pdo') {
$this->db->exec($sql);
pake_echo_action('pdo_mysql', $sql);
} elseif ($this->mode == 'mysqli') {
$result = $this->db->real_query($sql);
if (false === $result) {
throw new pakeException('MySQLi Error (' . $this->db->errno . ') ' . $this->db->error);
}
pake_echo_action('mysqli', $sql);
} elseif ($this->mode == 'mysql') {
$result = mysql_query($sql, $this->db);
if (false === $result) {
throw new pakeException('MySQL Error (' . mysql_errno() . ') ' . mysql_error());
}
pake_echo_action('mysql', $sql);
}
}
示例10: run_import_users
function run_import_users($task, $args)
{
if (!isset($args[0])) {
pake_echo_error('usage: pake i "users.yml"');
return false;
}
pake_echo_comment("Reading file. It can take awhile…");
$str = file_get_contents($args[0]);
$data = pakeYaml::loadString($str);
pake_echo_comment("Starting import…");
$len = count($data);
for ($i = 0; $i < $len; $i++) {
$row = $data[$i];
if (_create_user($row['login'], $row['password'], $row['data'])) {
pake_echo_action('user+', "({$i} of {$len}) " . $row['login']);
} else {
pake_echo_comment('already exists: ' . "({$i} of {$len}) " . $row['login']);
}
}
}
示例11: request
/**
* execute HTTP Request
*
* @param string $method
* @param string $url
* @param mixed $query_data string or array
* @param mixed $body string or array
* @param array $headers
* @param array $options
* @return string
*/
public static function request($method, $url, $query_data = null, $body = null, array $headers = array(), array $options = array())
{
$method = strtoupper($method);
$_options = array('method' => $method, 'user_agent' => 'pake ' . pakeApp::VERSION, 'ignore_errors' => true);
if (null !== $body) {
if (is_array($body)) {
$body = http_build_query($body);
}
$_options['content'] = $body;
}
if (count($headers) > 0) {
$_options['header'] = implode("\r\n", $headers) . "\r\n";
}
$options = array_merge($_options, $options);
if (null !== $query_data) {
if (is_array($query_data)) {
$query_data = http_build_query($query_data);
}
$url .= '?' . $query_data;
}
$context = stream_context_create(array('http' => $options));
$stream = fopen($url, 'r', false, $context);
if (false === $stream) {
throw new pakeException('HTTP request failed');
}
pake_echo_action('HTTP ' . $method, $url);
$meta = stream_get_meta_data($stream);
$response = stream_get_contents($stream);
fclose($stream);
$status = $meta['wrapper_data'][0];
$code = substr($status, 9, 3);
if ($status > 400) {
throw new pakeException('http request returned: ' . $status);
}
return $response;
}
示例12: run_app
public static function run_app($task, $args)
{
if (isset($args[0])) {
$config_file = $args[0];
} else {
$config_file = getcwd() . '/config.yaml';
}
pake_echo_comment('Loading configuration…');
if (!file_exists($config_file)) {
throw new \pakeException("Configuration file is not found: " . $config_file);
}
$config = \pakeYaml::loadFile($config_file);
$runner = new Runner();
foreach ($config['servers'] as $server) {
if (!class_exists($server['app']['class'])) {
require dirname($config_file) . '/' . $server['app']['file'];
pake_echo_action('load class', $server['app']['class']);
}
$runner->addServer($server['app']['class'], $server['app']['middlewares'], $server['protocol'], $server['socket'], $server['min-children'], $server['max-children']);
pake_echo_action('register', $server['app']['class'] . ' server via ' . $server['protocol'] . ' at ' . $server['socket'] . '. (' . $server['min-children'] . '-' . $server['max-children'] . ' children)');
}
pake_echo_comment('Starting server…');
$runner->go();
}
示例13: unrecordMigration
protected function unrecordMigration($version)
{
$version = $this->cleanVersion($version);
$this->executeUpdate("DELETE FROM schema_migration WHERE version='{$version}'");
pake_echo_action('migrations', "rollback version {$version}");
}
示例14: run_update_version_history
/**
* Updates the "eZ CP version history" document, currently hosted on pubsvn.ez.no.
*
* Options: --public-keyfile=<...> --private-keyfile=<...> --user=<...> --private-keypasswd=<...>
*
* @todo add support for getting ssl certs options in config settings
*/
public static function run_update_version_history($task = null, $args = array(), $cliopts = array())
{
$opts = self::getOpts($args, $cliopts);
$public_keyfile = @$cliopts['public-keyfile'];
$private_keyfile = @$cliopts['private-keyfile'];
$private_keypasswd = @$cliopts['private-keypasswd'];
$user = @$cliopts['user'];
// get file
$srv = "http://pubsvn.ez.no";
$filename = "/ezpublish_version_history/ez_history.csv";
$fullfilename = $srv . $filename;
$remotefilename = '/mnt/pubsvn.ez.no/www/' . $filename;
$file = pake_read_file($fullfilename);
if ("" == $file) {
throw new pakeException("Couldn't download {$fullfilename} file");
}
// patch it
/// @todo test that what we got looks at least a bit like what we expect
$lines = preg_split("/\r?\n/", $file);
$lines[0] .= $opts['version']['alias'] . ',';
$lines[1] .= strftime('%Y/%m/%d') . ',';
$file = implode("\n", $lines);
/// @todo: back up the original as well (upload 1st to srv the unpatched version with a different name, then the new version)
// upload it: we use curl for sftp
$randfile = tempnam(sys_get_temp_dir(), 'EZP');
pake_write_file($randfile, $file, true);
$fp = fopen($randfile, 'rb');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, str_replace('http://', 'sftp://@', $srv) . $remotefilename);
if ($user != "") {
curl_setopt($ch, CURLOPT_USERPWD, $user);
}
if ($public_keyfile != "") {
curl_setopt($ch, CURLOPT_SSH_PUBLIC_KEYFILE, $public_keyfile);
}
if ($private_keyfile != "") {
curl_setopt($ch, CURLOPT_SSH_PRIVATE_KEYFILE, $private_keyfile);
}
if ($private_keypasswd != "") {
curl_setopt($ch, CURLOPT_KEYPASSWD, $private_keypasswd);
}
curl_setopt($ch, CURLOPT_UPLOAD, 1);
curl_setopt($ch, CURLOPT_INFILE, $fp);
// set size of the file, which isn't _mandatory_ but helps libcurl to do
// extra error checking on the upload.
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($randfile));
$ok = curl_exec($ch);
$errinfo = curl_error($ch);
curl_close($ch);
fclose($fp);
pake_unlink($randfile);
if (!$ok) {
throw new pakeException("Couldn't write {$fullfilename} file: " . $errinfo);
}
pake_echo_action("file+", $filename);
}
示例15: _uninstall_web_content
function _uninstall_web_content($plugin_name)
{
$web_dir = sfConfig::get('sf_plugins_dir') . DIRECTORY_SEPARATOR . $plugin_name . DIRECTORY_SEPARATOR . 'web';
$target_dir = sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . $plugin_name;
if (is_dir($web_dir) && is_dir($target_dir)) {
pake_echo_action('plugin', 'uninstalling web data for plugin');
if (is_link($target_dir)) {
pake_remove($target_dir, '');
} else {
pake_remove(pakeFinder::type('any'), $target_dir);
pake_remove($target_dir, '');
}
}
}