get() public static method

public static get ( ) : Deployer
return Deployer
Esempio n. 1
0
                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}");
            }
        } catch (\RuntimeException $e) {
            $formatter = \Deployer\Deployer::get()->getHelper('formatter');
            $errorMessage = ["Unable to setup correct permissions for writable dirs.                  ", "You need co configure sudo's sudoers files to don't prompt for password,", "or setup correct permissions manually.                                  "];
            write($formatter->formatBlock($errorMessage, 'error', true));
            throw $e;
        }
    }
})->desc('Make writable dirs');
/**
 * Installing vendors tasks.
 */
task('deploy:vendors', function () {
    if (commandExist('composer')) {
        $composer = 'composer';
    } else {
        run("cd {{release_path}} && curl -sS https://getcomposer.org/installer | php");
        $composer = 'php composer.phar';
Esempio n. 2
0
/**
 * @param string $message
 * @return string
 * @codeCoverageIgnore
 */
function askHiddenResponse($message)
{
    if (isQuiet()) {
        return '';
    }
    $helper = Deployer::get()->getHelper('question');
    $message = "<question>{$message}</question> ";
    $question = new \Symfony\Component\Console\Question\Question($message);
    $question->setHidden(true);
    $question->setHiddenFallback(false);
    return $helper->ask(input(), output(), $question);
}
Esempio n. 3
0
<?php

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

use Deployer\Task\Context;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Style\SymfonyStyle;
desc('Print server configuration');
task('config:dump', function () {
    $server = Context::get()->getServer();
    $config = Deployer::get()->config;
    $env = Context::get()->getEnvironment();
    $dump = [];
    foreach ($config as $name => $value) {
        try {
            $env->get($name);
        } catch (\RuntimeException $exception) {
            // Ignore fails.
            $message = 'Failed to dump';
            $env->set($name, output()->isDecorated() ? "{$message}" : $message);
        }
    }
    foreach ($env->getValues() as $name => $value) {
        if (is_array($value)) {
            $value = json_encode($value);
        } elseif (is_bool($value)) {
Esempio n. 4
0
 public function testInstance()
 {
     $this->assertEquals($this->deployer, Deployer::get());
 }
Esempio n. 5
0
 /**
  * @param string $name
  * @return boolean
  */
 public static function hasDefault($name)
 {
     return isset(Deployer::get()->config[$name]);
 }
Esempio n. 6
0
 /**
  * @param string $serverName
  * @param string $exceptionClass
  * @param string $message
  */
 public function taskException($serverName, $exceptionClass, $message)
 {
     $formatter = Deployer::get()->getHelper('formatter');
     $messages = explode("\n", $message);
     array_unshift($messages, "Exception [{$exceptionClass}] on [{$serverName}] server:");
     $this->output->writeln($formatter->formatBlock($messages, 'error', true));
 }
Esempio n. 7
0
 /**
  * @param string $name
  * @param bool|int|string|array $default
  * @return bool|int|string|array
  * @throws \RuntimeException
  */
 public function get($name, $default = null)
 {
     if ($this->values->has($name)) {
         if ($this->isClosure($this->values[$name])) {
             $value = $this->values[$name] = call_user_func($this->values[$name]);
         } else {
             $value = $this->values[$name];
         }
     } else {
         $config = Deployer::get()->config;
         if (isset($config[$name])) {
             if ($this->isClosure($config[$name])) {
                 $value = $this->values[$name] = call_user_func($config[$name]);
             } else {
                 $value = $this->values[$name] = $config[$name];
             }
         } else {
             if (null === $default) {
                 throw new \RuntimeException("Configuration parameter `{$name}` does not exists.");
             } else {
                 $value = $default;
             }
         }
     }
     return $this->parse($value);
 }