protected function findPhpBinary()
  {
    if (defined('PHP_BINARY') && PHP_BINARY)
    {
      return PHP_BINARY;
    }

    if (false !== strpos(basename($php = $_SERVER['_']), 'php'))
    {
      return $php;
    }

    // from https://github.com/symfony/Process/blob/379b35a41a2749cf7361dda0f03e04410daaca4c/PhpExecutableFinder.php
    $suffixes = DIRECTORY_SEPARATOR == '\\' ? (getenv('PATHEXT') ? explode(PATH_SEPARATOR, getenv('PATHEXT')) : array('.exe', '.bat', '.cmd', '.com')) : array('');
    foreach ($suffixes as $suffix)
    {
      if (is_executable($php = PHP_BINDIR.DIRECTORY_SEPARATOR.'php'.$suffix))
      {
        return $php;
      }
    }

    if ($php = getenv('PHP_PEAR_PHP_BIN'))
    {
      if (is_executable($php))
      {
        return $php;
      }
    }

    return sfToolkit::getPhpCli();
  }
Example #2
0
 public function executeCommand(sfWebRequest $request)
 {
     $command = trim($request->getParameter("dm_command"));
     if (substr($command, 0, 2) == "sf") {
         $command = substr($command, 3);
         $exec = sprintf('%s "%s" %s --color', sfToolkit::getPhpCli(), dmProject::getRootDir() . '/symfony', $command);
     } else {
         $options = substr(trim($command), 0, 2) == 'll' || substr(trim($command), 0, 2) == 'ls' ? '--color' : '';
         $parts = explode(" ", $command);
         $parts[0] = dmArray::get($this->getAliases(), $parts[0], $parts[0]);
         $command = implode(" ", $parts);
         $parts = explode(" ", $command);
         $command = dmArray::get($this->getAliases(), $command, $command);
         if (!in_array($parts[0], $this->getCommands())) {
             return $this->renderText(sprintf("%s<li>This command is not available. You can do: <strong>%s</strong></li>", $this->renderCommand($command), implode(' ', $this->getCommands())));
         }
         $exec = sprintf("%s {$options}", $command);
     }
     ob_start();
     passthru($exec . ' 2>&1', $return);
     $raw = dmAnsiColorFormatHtmlRenderer::render(ob_get_clean());
     $arr = explode("\n", $raw);
     $res = $this->renderCommand($command);
     foreach ($arr as $a) {
         $res .= "<li class='dm_result_command'><pre>" . $a . "</pre></li>";
     }
     return $this->renderText($res);
 }
Example #3
0
 public function executeIndex(dmWebRequest $request)
 {
     $this->sitemap = $this->getService('xml_sitemap_generator')->setOption('domain', $this->getRequest()->getAbsoluteUrlRoot());
     if ($this->getUser()->can('system')) {
         $this->shellUser = dmConfig::canSystemCall() ? exec('whoami') : 'www-data';
         $this->phpCli = dmConfig::canSystemCall() ? sfToolkit::getPhpCli() : '/path/to/php';
         $this->rootDir = sfConfig::get('sf_root_dir');
         $this->domainName = $this->getRequest()->getHost();
     }
 }
Example #4
0
 public function sf($command)
 {
     try {
         $phpCli = sfToolkit::getPhpCli();
     } catch (sfException $e) {
         $this->lastExec = array('command' => $command, 'output' => $e->getMessage());
         return false;
     }
     $sfCommand = sprintf('%s "%s" %s', $phpCli, sfConfig::get('sf_root_dir') . '/symfony', $command);
     return $this->exec($sfCommand);
 }
Example #5
0
 public function initialize($t)
 {
     $this->t = $t;
     $this->tmp_dir = sfToolkit::getTmpDir() . DIRECTORY_SEPARATOR . 'symfony_cmd';
     if (is_dir($this->tmp_dir)) {
         $this->clearTmpDir();
         rmdir($this->tmp_dir);
     }
     mkdir($this->tmp_dir, 0777);
     $this->current_dir = getcwd();
     chdir($this->tmp_dir);
     $this->php_cli = sfToolkit::getPhpCli();
 }
 public function initialize($t)
 {
     $this->t = $t;
     $this->tmp_dir = sfToolkit::getTmpDir() . DS . 'sf_test_project';
     if (is_dir($this->tmp_dir)) {
         $this->clearTmpDir();
         rmdir($this->tmp_dir);
     }
     mkdir($this->tmp_dir, 0777);
     $this->current_dir = getcwd();
     chdir($this->tmp_dir);
     $this->php_cli = sfToolkit::getPhpCli();
 }
 public static function listenToCommandPostCommand(sfEvent $event)
 {
     static $firstCall = array();
     $task = $event->getSubject();
     $taskClass = get_class($task);
     $isFirstCall = isset($firstCall[$taskClass]) === false;
     $firstCall[$taskClass] = true;
     switch ($taskClass) {
         case 'sfDoctrineDataLoadTask':
             if ($isFirstCall) {
                 passthru(sprintf('%s %s/symfony jmsPaymentPlugin:updateRates', sfToolkit::getPhpCli(), sfConfig::get('sf_root_dir')));
             }
             break;
     }
 }
Example #8
0
 public function executeIndex(dmWebRequest $request)
 {
     $this->engine = $this->getService('search_engine');
     $this->form = $this->getSearchForm();
     if ($this->query = trim($request->getParameter('query'))) {
         $this->form->bind(array('query' => $this->query));
         $this->pager = $this->getSearchPager($this->query);
     } else {
         $this->pager = null;
     }
     if ($this->getUser()->can('system')) {
         $this->shellUser = dmConfig::canSystemCall() ? exec('whoami') : 'www-data';
         $this->phpCli = dmConfig::canSystemCall() ? sfToolkit::getPhpCli() : '/path/to/php';
         $this->rootDir = sfConfig::get('sf_root_dir');
     }
 }
 public function executeExport(sfWebRequest $request)
  { 

        $cmd = " > /dev/null &";

   exec(
        sprintf(
          '%s %s/symfony rockstep:csv --report=%s --go'.$cmd, 
            sfToolkit::getPhpCli(), 
            sfConfig::get('sf_root_dir'), 
            'classes'),
        $returnVar
    );


    // do nothing


  }
 public function __construct($t)
 {
     $this->t = $t;
     $this->cli = sfToolkit::getPhpCli();
 }
Example #11
0
if (count($cultures) > 0) {
    $this->logSection('i18n', 'enabling i18n in Sympal with cultures: ' . implode(', ', $cultures));
    $command = sprintf('%s "%s" %s', sfToolkit::getPhpCli(), sfConfig::get('sf_root_dir') . '/symfony', 'sympal:configure ' . sprintf('i18n=true language_codes="[%s]"', implode(',', $cultures)));
    $this->logBlock($command, 'INFO');
    $this->getFilesystem()->execute($command, $out, $err);
    $this->logSection('i18n', sprintf('enabling i18n in application "%s"', $application));
    $settingsFilename = sfConfig::get('sf_apps_dir') . '/' . $application . '/config/settings.yml';
    $settings = file_get_contents($settingsFilename);
    $settings .= <<<EOF

    i18n: true
    default_culture: {$cultures[0]}
EOF;
    file_put_contents($settingsFilename, $settings);
}
// execute sympal installation
$command = sprintf('%s "%s" %s', sfToolkit::getPhpCli(), sfConfig::get('sf_root_dir') . '/symfony', 'sympal:install ' . $application . ' --force-reinstall --email-address="' . $emailAddress . '" --username="******" --password="******" --no-confirmation --db-dsn="' . $db['dsn'] . '" --db-username="******" --db-password="******" --first-name="' . $firstName . '" --last-name="' . $lastName . '"');
$this->logBlock($command, 'INFO');
$this->getFilesystem()->execute($command);
// fix permission for common directories
$fixPerms = new sfProjectPermissionsTask($this->dispatcher, $this->formatter);
$fixPerms->setCommandApplication($this->commandApplication);
$fixPerms->setConfiguration($this->configuration);
$fixPerms->run();
$this->replaceTokens();
$this->log(null);
$this->logSection('sympal', sprintf('Sympal was installed successfully...', $application));
$url = 'http://localhost/' . $application . '_dev.php/security/signin';
$this->logSection('sympal', sprintf('Open your browser to "%s"', $url));
$this->logSection('sympal', sprintf('You can signin with the username "%s" and password "%s"', $username, $password));
exit;
Example #12
0
 * ****** Step4: Collecting Information & Configuring sympal ***************
 */
$application = $this->askAndValidate('What would you like your first application to be called? An application with this name will be generated for you.', new sfValidatorString(), array('style' => 'QUESTION_LARGE'));
$validator = new sfValidatorEmail();
$emailAddress = $this->askAndValidate('What is your e-mail address? (will used as author in config/properties.ini)', $validator, array('style' => 'QUESTION_LARGE'));
$this->logSection('sympal', '...setup database');
$db = setupDatabase($this);
$this->runTask('configure:database', array('dsn' => $db['dsn'], 'username' => $db['username'], 'password' => $db['password']));
$this->logSection('sympal', 'Configuring author');
$this->runTask('configure:author', sprintf("'%s'", $emailAddress));
$this->logSection('sympal', sprintf('Generating app %s', $application));
$this->runTask('generate:app', $application);
// install sympal
$this->logSection('sympal', 'Sympal is now installing itself into the symfony application.
  This will take a while, please be patient...');
$command = sprintf('%s "%s" %s', sfToolkit::getPhpCli(), sfConfig::get('sf_root_dir') . '/symfony', 'sympal:install ' . $application . ' --no-confirmation');
passthru($command);
/*
 * Fix permission for common directories
 * 
 * Must be done because we exist from the project generate task prematurely
 * so that we can show the pretty message about how to get to your site
 */
$fixPerms = new sfProjectPermissionsTask($this->dispatcher, $this->formatter);
$fixPerms->setCommandApplication($this->commandApplication);
$fixPerms->setConfiguration($this->configuration);
$fixPerms->run();
// replace tokens, do this since we exit the project install below
$this->replaceTokens();
// symlink the sf directory
$rootdir = getcwd();
Example #13
0
/*
 * APPLY
 */
$this->logBlock('Your configuration is valid', 'INFO_LARGE');
usleep(1000000);
$sendReports = $this->askConfirmation(array('Send anonymous reports about plugins used to improve http://diem-project.org/plugins (Y/n)'), 'QUESTION_LARGE', true);
if (!$this->askConfirmation(array('The installation will remove all data in the ' . $settings['database']['name'] . ' database.', '', 'Are you sure you want to proceed? (Y/n)'), 'QUESTION_LARGE', true)) {
    $this->logSection('diem', 'installation aborted');
    exit;
}
$this->filesystem->mirror(dmOs::join(sfConfig::get('dm_core_dir'), 'data/skeleton'), sfConfig::get('sf_root_dir'), sfFinder::type('any')->discard('.sf'), array('override' => true));
$this->replaceTokens(sfConfig::get('sf_config_dir'), array('SYMFONY_CORE_AUTOLOAD' => $symfonyCoreAutoload, 'DIEM_CORE_STARTER' => var_export(dmOs::join(sfConfig::get('dm_core_dir'), 'lib/core/dm.php'), true), 'DIEM_WEB_DIR' => "sfConfig::get('sf_root_dir').'/" . $settings['web_dir_name'] . "'", 'DIEM_CULTURE' => var_export($settings['culture'], true), 'SEND_REPORTS' => var_export($sendReports, true)));
$this->filesystem->remove(array(dmProject::rootify('web/css'), dmProject::rootify('web/css/main.css'), dmProject::rootify('web/images'), dmProject::rootify('data/fixtures'), dmProject::rootify('data/fixtures/fixtures.yml')));
if ('web' != $settings['web_dir_name']) {
    $this->filesystem->rename(dmProject::rootify('web'), dmProject::rootify($settings['web_dir_name']));
}
$db = $settings['database'];
$this->runTask('configure:database', array('dsn' => $db['dsn'], 'username' => $db['user'], 'password' => $db['password']));
try {
    if ('/' !== DIRECTORY_SEPARATOR) {
        throw new Exception('Automatic install disabled for windows servers');
    }
    $this->logBlock('Installing ' . $projectKey . '. This may take some time.', 'INFO_LARGE');
    $out = $err = null;
    $this->getFilesystem()->execute(sprintf('%s "%s" %s', sfToolkit::getPhpCli(), sfConfig::get('sf_root_dir') . '/symfony', 'dm:setup --no-confirmation'), $out, $err);
    $this->logBlock('Your project is now ready to be accessed by the web. Try it out on admin_dev.php.', 'INFO_LARGE');
    $this->logBlock('Your username is "admin" and your password is ' . (empty($settings['database']['password']) ? '"admin"' : 'the database password'), 'INFO_LARGE');
} catch (Exception $e) {
    $this->logBlock('There is one last thing you need to do.  Please run "php symfony dm:setup"', 'INFO_LARGE');
}
exit;
 /**
  * @return array
  */
 protected function getDefaultArguments()
 {
     return array('php' => array(\sfToolkit::getPhpCli()), 'directories' => array(\sfConfig::get('sf_test_dir') . '/unit/'));
 }
  public function executeTaskExecute()
  {
    if(!$this->getRequest()->isXmlHttpRequest())
    {
      $this->getResponse()->getParameterHolder()->removeNamespace('helper/asset/auto/stylesheet/last'); 
    }
    $this->php_cli = sfToolkit::getPhpCli();
    
    if($batch = $this->getRequestParameter('batch'))
    {
      $command = sprintf('%s "%s"', $this->php_cli, SF_ROOT_DIR.'/batch/'.$batch);
      $visible_command = 'php '.$batch; 
    }
    else
    {
      $command = $this->getRequestParameter('freetask');
      if(!$command)
      {
        if($args = $this->getRequestParameter('arg'))
        {
          ksort($args);
          $args = implode(' ', $args);
        }
        else
        {
          $args = '';
        }
        $command  = $this->getRequestParameter('task').' '.$args;
      }
      $visible_command = 'symfony '.$command; 
      $command = sprintf('%s "%s" %s', $this->php_cli, SF_ROOT_DIR.'/symfony', $command);
    }
    
    ob_start();
    passthru($command, $return);
    $content = ob_get_clean();

    $this->command = $visible_command;
    $this->output = $content;
  }
Example #16
0
 public function getCommand($threadClass, array $threadOptions = array())
 {
     return sprintf('%s "%s" %s "%s"', sfToolkit::getPhpCli(), $this->getCliFileFullPath(), $threadClass, str_replace('"', '\\"', serialize($threadOptions)));
 }
Example #17
0
 public static function canSystemCall()
 {
     if (function_exists('exec')) {
         try {
             $canSystemCall = (bool) sfToolkit::getPhpCli();
         } catch (sfException $e) {
             $canSystemCall = false;
         }
     } else {
         $canSystemCall = false;
     }
     return false;
 }
 /**
  * Getting command line interface
  *
  * @return string
  * @author Sergey Startsev
  */
 protected function getCli()
 {
     return ($cli = sfConfig::get(self::CONFIG_CLI)) ? $cli : sfToolkit::getPhpCli();
 }