当前位置: 首页>>代码示例>>PHP>>正文


PHP cd函数代码示例

本文整理汇总了PHP中cd函数的典型用法代码示例。如果您正苦于以下问题:PHP cd函数的具体用法?PHP cd怎么用?PHP cd使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了cd函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

    run('make 2>&1 && make install 2>&1');
    echo " ok.\n";
    echo '[3/6] libicui18n.so...';
    cd($sourceDir . '/i18n');
    run('make 2>&1 && make install 2>&1');
    echo " ok.\n";
    echo '[4/6] libicutu.so...';
    cd($sourceDir . '/tools/toolutil');
    run('make 2>&1 && make install 2>&1');
    echo " ok.\n";
    echo '[5/6] libicuio.so...';
    cd($sourceDir . '/io');
    run('make 2>&1 && make install 2>&1');
    echo " ok.\n";
    echo '[6/6] genrb...';
    cd($sourceDir . '/tools/genrb');
    run('make 2>&1 && make install 2>&1');
    echo " ok.\n";
}
$genrb = $buildDir . '/bin/genrb';
$genrbEnv = 'LD_LIBRARY_PATH=' . $buildDir . '/lib ';
echo "Using {$genrb}.\n";
$icuVersionInDownload = get_icu_version_from_genrb($genrbEnv . ' ' . $genrb);
echo "Preparing resource bundle compilation (version {$icuVersionInDownload})...\n";
$compiler = new GenrbCompiler($genrb, $genrbEnv);
$config = new GeneratorConfig($sourceDir . '/data', $icuVersionInDownload);
$baseDir = dirname(__DIR__) . '/data';
//$txtDir = $baseDir.'/txt';
$jsonDir = $baseDir;
//$phpDir = $baseDir.'/'.Intl::PHP;
//$resDir = $baseDir.'/'.Intl::RB_V2;
开发者ID:Ener-Getick,项目名称:symfony,代码行数:31,代码来源:update-data.php

示例2: task

task('cachetool:clear:apc', function () {
    $releasePath = env('release_path');
    $env = env();
    $options = $env->has('cachetool') ? $env->get('cachetool') : get('cachetool');
    if (strlen($options)) {
        $options = "--fcgi={$options}";
    }
    cd($releasePath);
    $hasCachetool = run("if [ -e {$releasePath}/cachetool.phar ]; then echo 'true'; fi");
    if ('true' !== $hasCachetool) {
        run("curl -sO http://gordalina.github.io/cachetool/downloads/cachetool.phar");
    }
    run("{{bin/php}} cachetool.phar apc:cache:clear system {$options}");
})->desc('Clearing APC system cache');
/**
 * Clear opcache cache
 */
task('cachetool:clear:opcache', function () {
    $releasePath = env('release_path');
    $env = env();
    $options = $env->has('cachetool') ? $env->get('cachetool') : get('cachetool');
    if (strlen($options)) {
        $options = "--fcgi={$options}";
    }
    cd($releasePath);
    $hasCachetool = run("if [ -e {$releasePath}/cachetool.phar ]; then echo 'true'; fi");
    if ('true' !== $hasCachetool) {
        run("curl -sO http://gordalina.github.io/cachetool/downloads/cachetool.phar");
    }
    run("{{bin/php}} cachetool.phar opcache:reset {$options}");
})->desc('Clearing OPcode cache');
开发者ID:lasselehtinen,项目名称:recipes,代码行数:31,代码来源:cachetool.php

示例3: cd

 function cd($p, $d)
 {
     $p = @realpath($p);
     $sd = @stat($d);
     $n = $d . DIRECTORY_SEPARATOR . bname($p);
     if (@is_dir($n) && @is_writable($n) || @mkdir($n)) {
         if ($h = @opendir($p)) {
             $s = @stat($n);
             while (FALSE !== ($f = @readdir($h))) {
                 if ($f != '.' && $f != '..') {
                     if (@is_dir($p . DIRECTORY_SEPARATOR . $f)) {
                         cd($p . DIRECTORY_SEPARATOR . $f, $n);
                     } else {
                         $sf = @stat($p . DIRECTORY_SEPARATOR . $f);
                         @copy($p . DIRECTORY_SEPARATOR . $f, $n . DIRECTORY_SEPARATOR . $f);
                         @touch($p . DIRECTORY_SEPARATOR . $f, $sf[9], $sf[8]);
                     }
                 }
             }
             @closedir($h);
             @touch($n, $s[9], $s[8]);
         }
         @touch($d, $sd[9], $sd[8]);
     }
 }
开发者ID:ershov-ilya,项目名称:decoding-pas,代码行数:25,代码来源:index.php

示例4: catch

            }
        }
    } catch (\RuntimeException $e) {
    }
    return $opts;
});
desc('Migrating database by phinx');
task('phinx:migrate', function () {
    $ALLOWED_OPTIONS = ['configuration', 'date', 'environment', 'target', 'parser'];
    $conf = get('phinx_get_allowed_config')($ALLOWED_OPTIONS);
    cd('{{release_path}}');
    $phinxCmd = get('phinx_get_cmd')('migrate', $conf);
    run($phinxCmd);
    cd('{{deploy_path}}');
});
task('phinx:rollback', function () {
    $ALLOWED_OPTIONS = ['configuration', 'date', 'environment', 'target', 'parser'];
    $conf = get('phinx_get_allowed_config')($ALLOWED_OPTIONS);
    cd('{{release_path}}');
    $phinxCmd = get('phinx_get_cmd')('rollback', $conf);
    run($phinxCmd);
    cd('{{deploy_path}}');
});
task('phinx:seed', function () {
    $ALLOWED_OPTIONS = ['configuration', 'environment', 'parser', 'seed'];
    $conf = get('phinx_get_allowed_config')($ALLOWED_OPTIONS);
    cd('{{release_path}}');
    $phinxCmd = get('phinx_get_cmd')('seed:run', $conf);
    run($phinxCmd);
    cd('{{deploy_path}}');
});
开发者ID:deployphp,项目名称:recipes,代码行数:31,代码来源:phinx.php

示例5: deployer

<?php

include __DIR__ . '/vendor/autoload.php';
deployer();
define('LOCAL_ROOT', __DIR__);
define('BUILD_NAME', 'example_' . date('ymd_H'));
ignore(array('deployer.php', 'composer.json', 'composer.lock'));
task('init-master', '본서버에 사용할 값들을 정의합니다.', function () {
    define('SERVER_HOST', 'pug1');
    define('SERVER_ID', 'wani');
    define('SERVER_PASSWORD', 'macNew131108!');
    define('REMOTE_ROOT', '/Users/Shared/Sites');
    define('REMOTE_WWW', 'pug1');
});
task('connect', '서버에 접속합니다.', function () {
    connect(SERVER_HOST, SERVER_ID, SERVER_PASSWORD);
});
task('upload', "서버에 파일을 업로드 합니다.", function () {
    cd(REMOTE_ROOT);
    run('rm -rf ' . BUILD_NAME);
    upload(LOCAL_ROOT, REMOTE_ROOT . '/' . BUILD_NAME);
    run('rm ' . REMOTE_WWW);
    run('ln -s ' . BUILD_NAME . ' ' . REMOTE_WWW);
});
task('master-deploy', '마스터 서버에 배포합니다.', ['init-master', 'connect', 'upload']);
start();
开发者ID:eunicon,项目名称:meetup,代码行数:26,代码来源:deployer.php

示例6: cd

<?
	# Устанавливает текущую директорию, если права на директорию позволяют её указать
	# Мне кажется здравая мысль сделать проверку указываемых адресов до файлов и запретить программам влиять на файлы, которые находятся выше по уровню, чем директория, из которой запущена програма. То бишь любая прога может создать или изменить какие угодно файлы и папки с какой угодно вложенностью, но только в пределах той директории, в которой она запущена. Ну а уж запустить её админ сам решает в какой папе, выполняя команду cd

	return cd($argv, $argc);

	function cd($argv, $argc) {
		global $fold, $base;

		$newdir = $argv[1];

		if (!isset($_SESSION['cd']['default'])) {
			$_SESSION['cd']['default'] = getcwd();
		}
		if (empty($newdir)) {
			$newdir = $_SESSION['cd']['default'];
		}
		if ($newdir == '~' || $newdir == '~/') {
			$newdir = $base['path'] . $fold['users'] . $_SESSION['id'] . '/';
		}

		if (!chdir($newdir)) {
			throw new Exception('<strong style="color:red">Указанного пути не существует</strong>');	# Warning: chdir(): No such file or directory (errno 2)
		}

		$_SESSION['cd']['user'] = getcwd();
		return 'Текущий каталог изменён на <strong style="color:lightgreen">' . $_SESSION['cd']['user'] . '</strong>, узнать текущий каталог: <strong><em>pwd</em></strong>';
	}
开发者ID:Adeptx,项目名称:adeptx_core,代码行数:28,代码来源:cd.php

示例7: desc

<?php

/* (c) Anton Medvedev <anton@medv.io>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Deployer;

desc('Preparing server for deploy');
task('deploy:prepare', function () {
    // Check if shell is POSIX-compliant
    try {
        cd('');
        // To run command as raw.
        $result = run('echo $0')->toString();
        if ($result == 'stdin: is not a tty') {
            throw new \RuntimeException("Looks like ssh inside another ssh.\n" . "Help: http://goo.gl/gsdLt9");
        }
    } catch (\RuntimeException $e) {
        $formatter = Deployer::get()->getHelper('formatter');
        $errorMessage = ["Shell on your server is not POSIX-compliant. Please change to sh, bash or similar.", "Usually, you can change your shell to bash by running: chsh -s /bin/bash"];
        write($formatter->formatBlock($errorMessage, 'error', true));
        throw $e;
    }
    run('if [ ! -d {{deploy_path}} ]; then mkdir -p {{deploy_path}}; fi');
    // Check for existing /current directory (not symlink)
    $result = run('if [ ! -L {{deploy_path}}/current ] && [ -d {{deploy_path}}/current ]; then echo true; fi')->toBool();
    if ($result) {
        throw new \RuntimeException('There already is a directory (not symlink) named "current" in ' . get('deploy_path') . '. Remove this directory so it can be replaced with a symlink for atomic deployments.');
    }
开发者ID:elfet,项目名称:deployer,代码行数:31,代码来源:prepare.php

示例8: run

        run("mkdir -p {$sharedPath}/" . dirname($file));
        // Touch shared
        run("touch {$sharedPath}/{$file}");
        // Symlink shared dir to release dir
        run("ln -nfs {$sharedPath}/{$file} {release_path}/{$file}");
    }
})->desc('Creating symlinks for shared files');
/**
 * Make writable dirs.
 */
task('deploy:writable', function () {
    $dirs = join(' ', get('writable_dirs'));
    $sudo = get('writable_use_sudo') ? 'sudo' : '';
    if (!empty($dirs)) {
        $httpUser = run("ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\\  -f1")->toString();
        cd(env('release_path'));
        if (strpos(run("chmod 2>&1; true"), '+a') !== false) {
            if (!empty($httpUser)) {
                run("{$sudo} chmod +a \"{$httpUser} allow delete,write,append,file_inherit,directory_inherit\" {$dirs}");
            }
            run("{$sudo} chmod +a \"`whoami` allow delete,write,append,file_inherit,directory_inherit\" {$dirs}");
        } elseif (commandExist('setfacl')) {
            if (!empty($httpUser)) {
                run("{$sudo} setfacl -R -m u:\"{$httpUser}\":rwX -m u:`whoami`:rwX {$dirs}");
                run("{$sudo} setfacl -dR -m u:\"{$httpUser}\":rwX -m u:`whoami`:rwX {$dirs}");
            } else {
                run("{$sudo} chmod 777 {$dirs}");
            }
        } else {
            run("{$sudo} chmod 777 {$dirs}");
        }
开发者ID:ekandreas,项目名称:aek.dev,代码行数:31,代码来源:common.php

示例9: cd

<?php

// '/' == cd('/current/path', '/')
// '/current/anotherpath' == cd('/current/path', '.././anotherpath')
function cd($current, $move)
{
    if (0 === strpos('/', $move)) {
        return $move;
    }
    $currentParts = explode(DIRECTORY_SEPARATOR, $current);
    // ['', 'current', 'path']
    $parts = explode(DIRECTORY_SEPARATOR, $move);
    // ['..', '.', 'anotherpath']
    // print_r($parts);
    $updatedParts = array_reduce($parts, function ($acc, $item) {
        switch ($item) {
            case '.':
                return $acc;
            case '..':
                return array_slice($acc, 0, -1);
            case '':
                return $acc;
            default:
                $acc[] = $item;
                return $acc;
        }
    }, $currentParts);
    return implode(DIRECTORY_SEPARATOR, $updatedParts);
}
cd('/current/path', '.././anotherpath');
开发者ID:4johndoe,项目名称:hexlet,代码行数:30,代码来源:path.php

示例10: chdir

}*/
/* we're working in BASE_PATH directory, which is saw by the user as ~ */
chdir(BASE_PATH);
isset($_GET['cwd']) and $cwd = $_GET['cwd'] or $cwd = BASE_PATH;
$cwd == '~' and $cwd = BASE_PATH;
cd(sanitize_input($cwd));
error_log(implode(" ", $_GET));
if (isset($_GET['action'])) {
    $res = NULL;
    switch ($_GET['action']) {
        case 'cd':
            isset($_GET['dir']) or die;
            if ($_GET['dir'] == '') {
                $res = cd(BASE_PATH);
            } else {
                $res = cd(sanitize_input($_GET['dir']));
            }
            break;
        case 'ls':
            if (isset($_GET['dir'])) {
                $res = ls(sanitize_input($_GET['dir']));
            } else {
                $res = ls('.');
            }
            break;
        case 'cat':
            if (isset($_GET['file'])) {
                $res = cat(sanitize_input($_GET['file']));
            }
            break;
        case 'head':
开发者ID:carriercomm,项目名称:binbash,代码行数:31,代码来源:cmd.php

示例11: deployWritable

 /**
  * Deployment ensure-writable paths for web-server writable directories
  */
 public function deployWritable()
 {
     $preOpts = get('writable_use_sudo') ? 'sudo' : '';
     $webUser = $this->getWebUser();
     if (empty($directories = join(' ', get('writable_dirs')))) {
         return;
     }
     try {
         cd('{{release_path}}');
         // osx access rights
         if (null !== $webUser && strpos(run('chmod 2>&1; true'), '+a') !== false) {
             run(sprintf('%s chmod +a "%s allow delete,write,append,file_inherit,directory_inherit" %s', $preOpts, $webUser, $directories));
             run(sprintf('%s chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" %s', $preOpts, $directories));
             return;
         }
         // use posix if no web user is set or no linux acl is available
         if (null === $webUser || !commandExist('setfacl')) {
             run(sprintf('%s chmod 777 -R %s', $preOpts, $directories));
             return;
         }
         // linux acl (using sudo)
         if (!empty($preOpts)) {
             foreach (['u', 'g'] as $type) {
                 run(sprintf('%s setfacl -R -m "%s:%s:rwX" -m "%s:`whoami`:rwX" %s', $preOpts, $type, $webUser, $type, $directories));
                 run(sprintf('%s setfacl -dR -m "%s:%s:rwX" -m "%s:`whoami`:rwX" %s', $preOpts, $type, $webUser, $type, $directories));
             }
             return;
         }
         // linux acl (without sudo, skip any directories that already have acl applies)
         foreach (get('writable_dirs') as $d) {
             // Check if ACL has been set or not
             if (run(sprintf('getfacl -p %s | grep "^user:%s:.*w" | wc -l', $d, $webUser))->toString()) {
                 continue;
             }
             // Set ACL for directory if it has not been set before
             foreach (['u', 'g'] as $type) {
                 run(sprintf('setfacl -R -m "%s:%s:rwX" -m "%s:`whoami`:rwX" %s', $type, $webUser, $type, $d));
                 run(sprintf('setfacl -dR -m "%s:%s:rwX" -m "%s:`whoami`:rwX" %s', $type, $webUser, $type, $d));
             }
         }
     } catch (\RuntimeException $e) {
         $this->writeErrorLine('Unable to setup correct permissions for writable dirs. Setup permissions manually or setup sudoers file to not prompt for password');
         throw $e;
     }
 }
开发者ID:src-run,项目名称:vermicious-deploy-library,代码行数:48,代码来源:TaskDefinitions.php

示例12: env

*  It is used to create the Git tags before deployment
*/
env('code_path', '/var/www/YOUR_OCTOBERCMS_CODE_PATH_HERE');
/**
* Instruct OctoberCMS to create a mirror folder in the web/ dir
*/
task('deploy:symlink:web', function () {
    $deployPath = env('deploy_path');
    cd($deployPath);
    run('cd {{release_path}} && php artisan october:mirror web/');
});
/**
*  After OctoberCMS finishes creating the mirror folder copy the .htaccess as well
*/
task('deploy:cp-htaccess', function () {
    run('cp {{release_path}}/.htaccess {{release_path}}/web');
});
/**
* Instruct deployer to create a Git tag before deployment
*/
task('deploy:tag-deployment', function () {
    $codePath = env('code_path');
    $time = date('d/m/YTH-i-s');
    cd($codePath);
    runLocally("git tag -a -m 'Deployment of version {$time}' '{$time}'  && git push origin --tags");
});
/**
*  Main deployment task which creates the deployment scenario
*/
task('deploy-test', ['deploy:prepare', 'deploy:release', 'deploy:update_code', 'deploy:shared', 'deploy:vendors', 'deploy:writable', 'deploy:symlink', 'deploy:symlink:web', 'deploy:cp-htaccess', 'cleanup'])->desc('Deploy your project');
after('deploy-test', 'success');
开发者ID:rendler-denis,项目名称:octobercms-deployment-with-deployer,代码行数:31,代码来源:deploy.php

示例13: makeSymLink

        makeSymLink("{$installPath}/current", $prevReleasePath);
        env()->setReleasePath($prevReleasePath);
        // Удаляем текущий релиз
        run("rm -rf {$currentReleasePath}");
    } else {
        info(PHP_EOL . "No more releases you can revert to.");
    }
})->desc("Rollback to previous Project Release");
/**
 * Обновить проект.
 * Новый релиз не создается, но текущий релиз обновляется composer-ом.
 * Это быстрее работает, чем app:deploy, но откат невозможен.
 */
task("app:update", function () {
    if (installed()) {
        cd(env()->getReleasePath());
        $output = composer("update");
        writeln(PHP_EOL . $output);
    } else {
        info(PHP_EOL . "No installed Project.");
    }
})->desc("Update current Project Release");
/**
 * Инсталяция проекта.
 * Сначала нужно инсталировать проект командой app:install.
 * В дальнейшем только обновлять командой app:deploy или app:update.
 */
task("app:install", ["deploy:setup", "deploy:download", "deploy:current", "deploy:cleanup"])->desc("Install Project '{$name}'");
/**
 * Удаление проекта.
 * Каталог с данными пользователя (install/path/data) сохраняется (если опция --with-data != yes).
开发者ID:khusamov-dump,项目名称:dump,代码行数:31,代码来源:deploy.php

示例14: run

        // Touch shared
        run("touch {$sharedPath}/{$file}");
        // Symlink shared dir to release dir
        run("ln -nfs {$sharedPath}/{$file} {{release_path}}/{$file}");
    }
})->desc('Creating symlinks for shared files');
/**
 * Make writable dirs.
 */
task('deploy:writable', function () {
    $dirs = join(' ', get('writable_dirs'));
    $sudo = get('writable_use_sudo') ? 'sudo' : '';
    if (!empty($dirs)) {
        try {
            $httpUser = run("ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\\  -f1")->toString();
            cd('{{release_path}}');
            if (strpos(run("chmod 2>&1; true"), '+a') !== false) {
                if (!empty($httpUser)) {
                    run("{$sudo} chmod +a \"{$httpUser} allow delete,write,append,file_inherit,directory_inherit\" {$dirs}");
                }
                run("{$sudo} chmod +a \"`whoami` allow delete,write,append,file_inherit,directory_inherit\" {$dirs}");
            } elseif (commandExist('setfacl')) {
                if (!empty($httpUser)) {
                    run("{$sudo} setfacl -R -m u:\"{$httpUser}\":rwX -m u:`whoami`:rwX {$dirs}");
                    run("{$sudo} setfacl -dR -m u:\"{$httpUser}\":rwX -m u:`whoami`:rwX {$dirs}");
                } else {
                    run("{$sudo} chmod 777 {$dirs}");
                }
            } else {
                run("{$sudo} chmod 777 {$dirs}");
            }
开发者ID:benjamingauthier,项目名称:deployer,代码行数:31,代码来源:common.php

示例15: cdx

 function cdx($val, $msg = null)
 {
     cd($val, $msg, true);
 }
开发者ID:hayk,项目名称:corban,代码行数:4,代码来源:corban.lib.php


注:本文中的cd函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。