/**
  * @param ConsoleOutput $output
  * @param ArgvInput     $input
  */
 public function __construct(ConsoleOutput $output, ArgvInput $input)
 {
     $this->output = $output;
     $kernel = $this->bootKernel($input->getParameterOption(['-e', '--env'], 'dev'));
     $this->container = $kernel->getContainer();
     $this->ormConnection = $this->container->get('database_connection');
     $this->schemaHelper = new SchemaHelper($this->container);
     $this->upgradeHelper = new UpgradeHelper($this->container);
     $this->mediaDirectory = $input->getParameterOption(['--media-directory'], $this->container->getParameter('kernel.root_dir') . self::MEDIA_DIR);
     $this->productMediaTable = $input->getParameterOption(['--product-media-table'], self::MEDIA_TABLE);
     $this->productTemplateTable = $input->getParameterOption(['--product-template-table'], self::TEMPLATE_TABLE);
     if (!is_dir($this->mediaDirectory)) {
         throw new \RuntimeException(sprintf('The media directory "%s" does not exist', $this->mediaDirectory));
     }
 }
예제 #2
0
 /**
  * Constructor. This is run before any modules are loaded, so we can
  * initialise the console here.
  *
  * @param ContainerInterface $container The service container
  * @param array|null 		 $arguments Arguments to pass into the Console component
  *
  * @todo Change the environment earlier if possible. Can we make the context
  * run something before even Cog is bootstrapped?
  */
 public function __construct(ContainerInterface $container, array $arguments = null)
 {
     $this->_services = $container;
     $this->_services['console.commands'] = function () {
         return new CommandCollection(array(new Command\EventList(), new Command\ModuleList(), new Command\RouteList(), new Command\RouteCollectionTree(), new Command\Setup(), new Command\Status(), new Command\TaskGenerate(), new Command\TaskList(), new Command\TaskRun(), new Command\TaskRunScheduled(), new Command\AssetDump(), new Command\AssetGenerator(), new Command\MigrateInstall(), new Command\MigrateRollback(), new Command\MigrateReset(), new Command\MigrateRefresh(), new Command\MigrateRun(), new Command\DeployEvent(), new Command\DeployPermissions(), new Command\ModuleNamespace(), new Command\CacheClear()));
     };
     $this->_services['console.app'] = function ($c) {
         $app = new Application();
         $app->setContainer($c);
         $app->getDefinition()->addOption(new InputOption('--' . $app::ENV_OPT_NAME, '', InputOption::VALUE_OPTIONAL, 'The Environment name.'));
         // Add the commands
         foreach ($c['console.commands'] as $command) {
             $app->add($command);
         }
         return $app;
     };
     if (null === $arguments) {
         $arguments = $_SERVER['argv'];
     }
     $input = new ArgvInput($arguments);
     if ($env = $input->getParameterOption(array('--env'), '')) {
         $this->_services['environment']->setWithInstallation($env);
     }
     // Setup a fake request context
     $this->_services['http.request.context'] = function ($c) {
         $context = new \Message\Cog\Routing\RequestContext();
         return $context;
     };
 }
 /**
  * Determine whether a CLI command is for compilation, and if so, clear the directory
  *
  * @throws \Magento\Framework\Exception\FileSystemException
  * @return void
  */
 public function handleCompilerEnvironment()
 {
     $compilationCommands = [DiCompileCommand::NAME, DiCompileMultiTenantCommand::NAME];
     $cmdName = $this->input->getFirstArgument();
     $isHelpOption = $this->input->hasParameterOption('--help') || $this->input->hasParameterOption('-h');
     if (!in_array($cmdName, $compilationCommands) || $isHelpOption) {
         return;
     }
     $generationDir = $cmdName === DiCompileMultiTenantCommand::NAME ? $this->input->getParameterOption(DiCompileMultiTenantCommand::INPUT_KEY_GENERATION) : null;
     if (!$generationDir) {
         $mageInitParams = $this->serviceManager->get(InitParamListener::BOOTSTRAP_PARAM);
         $mageDirs = isset($mageInitParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS]) ? $mageInitParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS] : [];
         $generationDir = (new DirectoryList(BP, $mageDirs))->getPath(DirectoryList::GENERATION);
     }
     if ($this->filesystemDriver->isExists($generationDir)) {
         $this->filesystemDriver->deleteDirectory($generationDir);
     }
 }
 public function __construct(ConsoleOutput $output, ArgvInput $input)
 {
     $this->output = $output;
     $env = $input->getParameterOption(['-e', '--env']);
     if (!$env) {
         $env = 'dev';
     }
     $this->kernel($env);
 }
 /**
  * @param ConsoleOutput $output
  * @param ArgvInput     $input
  */
 public function __construct(ConsoleOutput $output, ArgvInput $input)
 {
     $this->output = $output;
     $env = $input->getParameterOption(['-e', '--env']);
     if (!$env) {
         $env = 'dev';
     }
     $this->bootKernel($env);
     $schemaHelper = new SchemaHelper($this->container);
     $this->productTemplateTable = $schemaHelper->getTableOrCollection('product_template');
 }
예제 #6
0
 public static function runCLI($environment = 'dev', $debug = true)
 {
     set_time_limit(0);
     $input = new ArgvInput();
     $environment = $input->getParameterOption(array('--env', '-e'), $environment);
     $debug = !$input->hasParameterOption(array('--no-debug', '')) && $environment !== 'prod';
     if ($debug) {
         Debug::enable();
     }
     $kernel = new static($environment, $debug);
     $application = new Application($kernel);
     $application->run($input);
 }
예제 #7
0
 /**
  * @return bool
  */
 public function bootstrapOxid()
 {
     $input = new ArgvInput();
     if ($input->getParameterOption('--shopDir')) {
         $oxBootstrap = $input->getParameterOption('--shopDir') . '/bootstrap.php';
         if ($this->checkBootstrapOxidInclude($oxBootstrap) === true) {
             return true;
         }
         return false;
     }
     // try to guess where bootstrap.php is
     $currentWorkingDirectory = getcwd();
     do {
         $oxBootstrap = $currentWorkingDirectory . '/bootstrap.php';
         if ($this->checkBootstrapOxidInclude($oxBootstrap) === true) {
             return true;
             break;
         }
         $currentWorkingDirectory = dirname($currentWorkingDirectory);
     } while ($currentWorkingDirectory !== '/');
     return false;
 }
예제 #8
0
파일: Run.php 프로젝트: michaldudek/flavour
 /**
  * Runs Symfony2 in console mode.
  *
  * @param string $kernelClass Class name for the kernel to be ran.
  */
 public static function console($kernelClass)
 {
     set_time_limit(0);
     $input = new ArgvInput();
     // decide env and debug info based on cli params
     $env = $input->getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev');
     $debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(['--no-debug', '']) && $env !== 'prod';
     if ($debug) {
         Debug::enable();
     }
     $kernel = new $kernelClass($env, $debug);
     $application = new Application($kernel);
     $application->run($input);
 }
예제 #9
0
파일: Module.php 프로젝트: im286er/ent
 /**
  *
  * @param Event $event
  */
 public function loadCli(EventInterface $event)
 {
     $commands = array(new \Doctrine\ODM\MongoDB\Tools\Console\Command\QueryCommand(), new \Doctrine\ODM\MongoDB\Tools\Console\Command\GenerateDocumentsCommand(), new \Doctrine\ODM\MongoDB\Tools\Console\Command\GenerateRepositoriesCommand(), new \Doctrine\ODM\MongoDB\Tools\Console\Command\GenerateProxiesCommand(), new \Doctrine\ODM\MongoDB\Tools\Console\Command\GenerateHydratorsCommand(), new \Doctrine\ODM\MongoDB\Tools\Console\Command\Schema\CreateCommand(), new \Doctrine\ODM\MongoDB\Tools\Console\Command\Schema\DropCommand());
     foreach ($commands as $command) {
         $command->getDefinition()->addOption(new InputOption('documentmanager', null, InputOption::VALUE_OPTIONAL, 'The name of the documentmanager to use. If none is provided, it will use odm_default.'));
     }
     $cli = $event->getTarget();
     $cli->addCommands($commands);
     $arguments = new ArgvInput();
     $documentManagerName = $arguments->getParameterOption('--documentmanager');
     $documentManagerName = !empty($documentManagerName) ? $documentManagerName : 'odm_default';
     $documentManager = $event->getParam('ServiceManager')->get('doctrine.documentmanager.' . $documentManagerName);
     $documentHelper = new \Doctrine\ODM\MongoDB\Tools\Console\Helper\DocumentManagerHelper($documentManager);
     $cli->getHelperSet()->set($documentHelper, 'dm');
 }
예제 #10
0
 /**
  * @return string[]
  * @author Maximilian Ruta <*****@*****.**>
  */
 public function getBundles()
 {
     require_once $this->console->getAppDir() . '/AppKernel.php';
     $input = new ArgvInput();
     $env = $input->getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?: 'dev');
     $debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod';
     $kernel = new \AppKernel($env, $debug);
     $bundles = $kernel->registerBundles();
     $bundleMap = [];
     foreach ($bundles as $bundle) {
         $reflector = new \ReflectionClass($bundle);
         $bundlePath = dirname($reflector->getFileName());
         $bundleMap[$bundle->getName()] = $bundlePath;
     }
     return $bundleMap;
 }
예제 #11
0
 /**
  * Detect if a custom environment file matching the APP_ENV exists.
  *
  * @param \Illuminate\Contracts\Foundation\Application|\Notadd\Foundation\Application $app
  *
  * @return void
  */
 protected function checkForSpecificEnvironmentFile($app)
 {
     if (php_sapi_name() == 'cli') {
         $input = new ArgvInput();
         if ($input->hasParameterOption('--env')) {
             $file = $app->environmentFile() . '.' . $input->getParameterOption('--env');
             $this->loadEnvironmentFile($app, $file);
         }
     }
     if (!env('APP_ENV')) {
         return;
     }
     if (empty($file)) {
         $file = $app->environmentFile() . '.' . env('APP_ENV');
         $this->loadEnvironmentFile($app, $file);
     }
 }
예제 #12
0
 /**
  * @return ContainerBuilder
  */
 public function getContainer()
 {
     if ($this->container) {
         return $this->container;
     }
     // Load cli options:
     $input = new ArgvInput();
     $configPath = $input->getParameterOption(['--config', '-c'], $this->getConfigDefaultPath());
     // Make sure to set the full path when it is declared relative
     // This will fix some issues in windows.
     $filesystem = new Filesystem();
     if (!$filesystem->isAbsolutePath($configPath)) {
         $configPath = getcwd() . DIRECTORY_SEPARATOR . $configPath;
     }
     $this->container = new ContainerBuilder();
     $extension = new OctavaGeggsExtension();
     $this->container->registerExtension($extension);
     $loader = new YamlFileLoader($this->container, new FileLocator(dirname($configPath)));
     $loader->load(basename($configPath));
     $this->container->compile();
     return $this->container;
 }
 public function setEntityManager(Event $e)
 {
     /* @var $cli \Symfony\Component\Console\Application */
     $cli = $e->getTarget();
     // Set new option for all commands
     $commands = $cli->all();
     foreach ($commands as $command) {
         $command->getDefinition()->addOption(new InputOption('em', null, InputOption::VALUE_OPTIONAL, 'Set the name of your entity manager (overrides orm_default)'));
     }
     // Get command-line arguments
     $args = new ArgvInput();
     $em = $args->getParameterOption('--em');
     // Set the new em if needed
     if ($em) {
         /* @var $serviceLocator \Zend\ServiceManager\ServiceLocatorInterface */
         $serviceLocator = $e->getParam('ServiceManager');
         /* @var $entityManager \Doctrine\ORM\EntityManager */
         $entityManager = $serviceLocator->get(sprintf('doctrine.entitymanager.%s', $em));
         $helperSet = $cli->getHelperSet();
         $helperSet->set(new ConnectionHelper($entityManager->getConnection()), 'db');
         $helperSet->set(new EntityManagerHelper($entityManager), 'em');
     }
 }
예제 #14
0
 /**
  * Handles the brood default options/arguments.
  */
 public static final function ArgvInput()
 {
     # get the raw commands
     $raws = ['--env', '--timeout'];
     # get the options from Brood
     $options = [Brood::environmentOption(), Brood::timeoutOption()];
     $instances = [];
     $reflect = new ReflectionClass(InputOption::class);
     foreach ($options as $opt) {
         $instances[] = $reflect->newInstanceArgs($opt);
     }
     # still, listen to the php $_SERVER['argv']
     $cmd_input = new ArgvInput();
     # get the default brood options
     $brood_input = new ArgvInput($raws, new InputDefinition($instances));
     foreach ($raws as $raw) {
         if ($cmd_input->hasParameterOption([$raw])) {
             $val = $cmd_input->getParameterOption($raw);
             $val = is_numeric($val) ? (int) $val : $val;
             $brood_input->setOption(str_replace('-', '', $raw), $val);
         }
     }
     return $brood_input;
 }
예제 #15
0
 public function requestAction()
 {
     $request = $this->get('request');
     if ($request->isXmlHttpRequest() && $request->getMethod() == 'POST') {
         // retrieve command string
         $sf2Command = stripslashes($request->request->get('command'));
         if ($sf2Command == '.') {
             // this trick is used to give the possibility to have "php app/console" equivalent
             $sf2Command = 'list';
         }
         //TODO: not really efficient
         $app = $request->request->get('app') ? $request->request->get('app') : basename($this->get('kernel')->getRootDir());
         if (!in_array($app, $this->container->getParameter('sf2gen_console.apps'))) {
             return new Response('This application is not allowed...', 200);
             // set to 200 to allow console display
         }
         //Try to run a separate shell process
         if ($this->container->getParameter('sf2gen_console.new_process')) {
             //Try to run a separate shell process
             try {
                 $php = $this->getPhpExecutable();
                 $commandLine = $php . ' ' . $app . '/' . 'console ';
                 if (!empty($sf2Command)) {
                     $commandLine .= $sf2Command;
                 }
                 $p = new Process($commandLine, dirname($this->get('kernel')->getRootDir()), null, null, 30, array('suppress_errors' => false, 'bypass_shell' => false));
                 $p->run();
                 $output = $p->getOutput();
                 /*
                 if the process is not successful:
                 - 1) Symfony throws an error and ouput is not empty; continue without Exception.
                 - 2) Process throws an error and ouput is empty => Exception!
                 */
                 if (!$p->isSuccessful() && empty($output)) {
                     throw new \RuntimeException('Unabled to run the process.');
                 }
             } catch (\Exception $e) {
                 // not trying the other method. It is interesting to know where it is not working (single process or not)
                 return new Response(nl2br("The request failed when using a separated shell process. Try to use 'new_process: false' in configuration.\n Error : " . $e->getMessage()));
             }
         } else {
             //Try to execute a console within this process
             //TODO: fix cache:clear issue
             try {
                 //Prepare input
                 $args = preg_split("/ /", trim($sf2Command));
                 array_unshift($args, "fakecommandline");
                 //To simulate the console's arguments
                 $app = $args[1];
                 $input = new ArgvInput($args);
                 //Prepare output
                 ob_start();
                 $output = new StreamOutput(fopen("php://output", 'w'), StreamOutput::VERBOSITY_NORMAL, true, new OutputFormatterHtml(true));
                 //Start a kernel/console and an application
                 $env = $input->getParameterOption(array('--env', '-e'), 'dev');
                 $debug = !$input->hasParameterOption(array('--no-debug', ''));
                 $kernel = new \AppKernel($env, $debug);
                 $kernel->boot();
                 $application = new Application($kernel);
                 foreach ($kernel->getBundles() as $bundle) {
                     $bundle->registerCommands($application);
                 }
                 //integrate all availables commands
                 //Find, initialize and run the real command
                 $run = $application->find($app)->run($input, $output);
                 $output = ob_get_contents();
                 ob_end_clean();
             } catch (\Exception $e) {
                 return new Response(nl2br("The request failed  when using same process.\n Error : " . $e->getMessage()));
             }
         }
         // common response for both methods
         if (empty($output)) {
             $output = 'The command "' . $sf2Command . '" was successful.';
         }
         return new Response($this->convertOuput($output));
     }
     return new Response('This request was not found.', 404);
     // request is not a POST request
 }
예제 #16
0
 /**
  * @return array
  */
 protected function parseConfigurationFile()
 {
     $paths = array('phpspec.yml', 'phpspec.yml.dist');
     $input = new ArgvInput();
     if ($customPath = $input->getParameterOption(array('-c', '--config'))) {
         if (!file_exists($customPath)) {
             throw new FileNotFoundException('Custom configuration file not found at ' . $customPath);
         }
         $paths = array($customPath);
     }
     foreach ($paths as $path) {
         if ($path && file_exists($path) && ($config = Yaml::parse(file_get_contents($path)))) {
             return $config;
         }
     }
     return array();
 }
예제 #17
0
<?php

/**
 * Project: zaralab
 * Filename: console.php
 *
 * @author Miroslav Yovchev <*****@*****.**>
 * @since 31.10.15
 */
require __DIR__ . '/../vendor/autoload.php';
use Symfony\Component\Console\Input\ArgvInput;
use Zaralab\Framework\Console\App;
use Zaralab\Framework\Config;
// Override DEBUG/ENV
$input = new ArgvInput();
$env = $input->getParameterOption(array('--env', '-e'), null);
$debug = $env === null ? null : !$input->hasParameterOption(array('--no-debug', '')) && $env != 'prod';
$container = Config::containerFactory(__DIR__, $env, $debug);
// Set current directory to application root so we can find root config files
chdir(__DIR__ . '/..');
$app = new App($container);
$app->setCatchExceptions(true);
// Set up DIC
require __DIR__ . '/dependencies.php';
$app->run($input);
예제 #18
0
$phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx);
$phpbb_class_loader->register();
$phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx);
extract($phpbb_config_php_file->get_all());
if (!defined('PHPBB_ENVIRONMENT')) {
    @define('PHPBB_ENVIRONMENT', 'production');
}
require $phpbb_root_path . 'includes/constants.' . $phpEx;
require $phpbb_root_path . 'includes/functions.' . $phpEx;
require $phpbb_root_path . 'includes/functions_admin.' . $phpEx;
require $phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx;
$phpbb_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx);
$phpbb_container = $phpbb_container_builder->with_config($phpbb_config_php_file);
$input = new ArgvInput();
if ($input->hasParameterOption(array('--env'))) {
    $phpbb_container_builder->with_environment($input->getParameterOption('--env'));
}
if ($input->hasParameterOption(array('--safe-mode'))) {
    $phpbb_container_builder->without_extensions();
    $phpbb_container_builder->without_cache();
} else {
    $phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx);
    $phpbb_class_loader_ext->register();
}
$phpbb_container = $phpbb_container_builder->get_container();
$phpbb_container->get('request')->enable_super_globals();
require $phpbb_root_path . 'includes/compatibility_globals.' . $phpEx;
/* @var $user \phpbb\user */
$user = $phpbb_container->get('user');
$user->data['user_id'] = ANONYMOUS;
$user->ip = '127.0.0.1';
예제 #19
0
#!/usr/bin/env php
<?php 
/**
 *
 * 
 * @author Richard Fullmer <*****@*****.**>
 */
require_once __DIR__ . "/autoload.php";
require_once __DIR__ . "/AppKernel.php";
use Opensoft\Drools\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
$input = new ArgvInput();
$env = $input->getParameterOption(array('--env', '-e'), 'dev');
$debug = !$input->getParameterOption(array('--no-debug'));
$kernel = new AppKernel($env, $debug);
$console = new Application($kernel);
$console->run();
예제 #20
0
 /**
  * @return \Symfony\Component\DependencyInjection\ContainerBuilder
  */
 protected function getContainer()
 {
     if ($this->container) {
         return $this->container;
     }
     // Load cli options:
     $input = new ArgvInput();
     $configPath = $input->getParameterOption(array('--config', '-c'), $this->getConfigDefaultPath());
     // Make sure to set the full path when it is declared relative
     // This will fix some issues in windows.
     $filesystem = new Filesystem();
     if (!$filesystem->isAbsolutePath($configPath)) {
         $configPath = getcwd() . DIRECTORY_SEPARATOR . $configPath;
     }
     // Build the service container:
     $this->container = ContainerFactory::buildFromConfiguration($configPath);
     return $this->container;
 }
예제 #21
0
파일: bldr.php 프로젝트: kangkot/bldr
            case 'k':
                $value *= 1024;
        }
        return $value;
    };
    $memoryLimit = trim(ini_get('memory_limit'));
    // Increase memory_limit if it is lower than 512M
    if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 512 * 1024 * 1024) {
        @ini_set('memory_limit', '512M');
    }
    unset($memoryInBytes, $memoryLimit);
}
use Dflydev\EmbeddedComposer\Core\EmbeddedComposerBuilder;
use Symfony\Component\Console\Input\ArgvInput;
$input = new ArgvInput();
if ($projectDir = $input->getParameterOption('--project-dir')) {
    if (false !== strpos($projectDir, '~') && function_exists('posix_getuid')) {
        $info = posix_getpwuid(posix_getuid());
        $projectDir = str_replace('~', $info['dir'], $projectDir);
    }
    if (!is_dir($projectDir)) {
        throw new \InvalidArgumentException(sprintf("Specified project directory %s does not exist", $projectDir));
    }
    chdir($projectDir);
}
if (!($vendorDir = $input->getParameterOption('--vendor-dir'))) {
    $vendorDir = '.bldr/vendor/';
}
$embeddedComposerBuilder = new EmbeddedComposerBuilder($classLoader);
$embeddedComposer = $embeddedComposerBuilder->setComposerFilename('bldr.json')->setVendorDirectory($vendorDir)->build();
$embeddedComposer->processAdditionalAutoloads();
예제 #22
0
        exit;
    };
    pcntl_signal(SIGTERM, $exit);
    pcntl_signal(SIGHUP, $exit);
    pcntl_signal(SIGINT, $exit);
}
if (isset($_SERVER['REQUEST_METHOD'])) {
    die('Only available through command-line.');
}
require_once 'tiki-filter-base.php';
require_once 'lib/init/initlib.php';
include_once 'lib/init/tra.php';
require_once 'lib/setup/tikisetup.class.php';
require_once 'lib/setup/twversion.class.php';
$input = new ArgvInput();
if (false !== ($site = $input->getParameterOption(array('--site')))) {
    $_SERVER['TIKI_VIRTUAL'] = $site;
}
$local_php = TikiInit::getCredentialsFile();
$console = new Tiki\Command\Application();
$console->add(new Tiki\Command\ConfigureCommand());
if (is_file($local_php) || TikiInit::getEnvironmentCredentials()) {
    require 'db/tiki-db.php';
    $console->add(new Tiki\Command\InstallCommand());
    $console->add(new Tiki\Command\UpdateCommand());
} else {
    $console->add(new Tiki\Command\UnavailableCommand('database:install'));
    $console->add(new Tiki\Command\UnavailableCommand('database:update'));
}
$installer = $installer = new Installer();
$isInstalled = $installer->isInstalled();
예제 #23
0
<?php

use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;
// if you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
//umask(0000);
set_time_limit(0);
$input = new ArgvInput();
$env = $input->getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?: 'dev');
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod';
if ($debug) {
    Debug::enable();
}
$kernel = new $kernelClass($env, $debug);
$application = new Application($kernel);
$application->run($input);
예제 #24
0
     $application = $event->getCommand()->getApplication();
     $inputDefinition = $application->getDefinition();
     $inputDefinition->addOption(new InputOption('env', array('e'), InputOption::VALUE_OPTIONAL, 'The Environment name.', 'dev'));
 });
 $dispatcher->addListener(ConsoleEvents::COMMAND, function (ConsoleCommandEvent $event) {
     $application = $event->getCommand()->getApplication();
     $memLimit = ini_get('memory_limit');
     if ($memLimit == -1) {
         $memLimit = 'Unlimited';
     }
     $inputDefinition = $application->getDefinition();
     $inputDefinition->addOption(new InputOption('mem', array('m'), InputOption::VALUE_OPTIONAL, 'Specifiy max memory in megabytes.', $memLimit));
 });
 // Grab the --env parameter from the command line and use 'dev' as the default.
 $input = new ArgvInput();
 $env = $input->getParameterOption(array('--env', '-e'), getenv(DoctrineConsole::ENV) ?: 'dev');
 ///// Load Config
 $configDir = "./config";
 if (!@file_exists("{$configDir}/config.yml")) {
     throw new \Exception("File: {$configDir}/config.yml does not exist.");
 }
 if (!@file_exists("{$configDir}/config_{$env}.yml")) {
     throw new \Exception("File: {$configDir}/config_{$env}.yml does not exist.");
 }
 try {
     $config = Yaml\Yaml::parse("{$configDir}/config.yml");
     $configEnv = Yaml\Yaml::parse("{$configDir}/config_{$env}.yml");
 } catch (Yaml\Exception\ParseException $e) {
     throw new \Exception($e->getMessage());
 }
 $config = Arr::merge($config, $configEnv);
예제 #25
0
<?php

/*
 * This file is part of the Trinity project.
 */
set_time_limit(0);
require __DIR__ . '/../Tests/Functional/app/AppKernel.php';
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;
use Trinity\Bundle\SearchBundle\Tests\Functional\app\AppKernel;
$input = new ArgvInput();
$env = $input->getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev');
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(['--no-debug', '']) && $env !== 'prod';
if ($debug) {
    Debug::enable();
}
$kernel = new AppKernel($env, $debug);
$application = new Application($kernel);
$application->run($input);
예제 #26
0
파일: console.php 프로젝트: rjsmelo/tiki
        exit;
    };
    pcntl_signal(SIGTERM, $exit);
    pcntl_signal(SIGHUP, $exit);
    pcntl_signal(SIGINT, $exit);
}
if (isset($_SERVER['REQUEST_METHOD'])) {
    die('Only available through command-line.');
}
require_once 'tiki-filter-base.php';
require_once 'lib/init/initlib.php';
include_once 'lib/init/tra.php';
require_once 'lib/setup/tikisetup.class.php';
require_once 'lib/setup/twversion.class.php';
$input = new ArgvInput();
if (false !== ($site = $input->getParameterOption(array('--site')))) {
    $_SERVER['TIKI_VIRTUAL'] = $site;
}
$local_php = TikiInit::getCredentialsFile();
if (!is_readable($local_php)) {
    die("Credentials file local.php not found. See http://doc.tiki.org/Installation for more information.\n");
}
$console = new Tiki\Command\Application();
$console->add(new Tiki\Command\ConfigureCommand());
if (is_file($local_php) || TikiInit::getEnvironmentCredentials()) {
    require_once 'db/tiki-db.php';
    $console->add(new Tiki\Command\InstallCommand());
    $console->add(new Tiki\Command\UpdateCommand());
    $console->add(new Tiki\Command\MultiTikiListCommand());
    $console->add(new Tiki\Command\MultiTikiMoveCommand());
} else {
예제 #27
0
파일: sculpin.php 프로젝트: leosanm/sculpin
        }
        return $value;
    };
    $memoryLimit = trim(ini_get('memory_limit'));
    // Increase memory_limit if it is lower than 512M
    if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 512 * 1024 * 1024) {
        @ini_set('memory_limit', '512M');
    }
    unset($memoryInBytes, $memoryLimit);
}
use Dflydev\EmbeddedComposer\Core\EmbeddedComposerBuilder;
use Sculpin\Bundle\SculpinBundle\Console\Application;
use Sculpin\Bundle\SculpinBundle\HttpKernel\KernelFactory;
use Symfony\Component\Console\Input\ArgvInput;
$input = new ArgvInput();
if ($projectDir = $input->getParameterOption('--project-dir')) {
    if (false !== strpos($projectDir, '~') && function_exists('posix_getuid')) {
        $info = posix_getpwuid(posix_getuid());
        $projectDir = str_replace('~', $info['dir'], $projectDir);
    }
    if (!is_dir($projectDir)) {
        throw new \InvalidArgumentException(sprintf("Specified project directory %s does not exist", $projectDir));
    }
    chdir($projectDir);
}
$embeddedComposerBuilder = new EmbeddedComposerBuilder($classLoader);
$embeddedComposer = $embeddedComposerBuilder->setComposerFilename('sculpin.json')->setVendorDirectory('.sculpin')->build();
$embeddedComposer->processAdditionalAutoloads();
$kernel = KernelFactory::create($input);
$application = new Application($kernel, $embeddedComposer);
$application->run($input);
예제 #28
0
    echo 'Please execute "composer install" from the command line to install the required dependencies for Shopware 5';
    echo '<h2>Fehler</h2>';
    echo 'Bitte führen Sie zuerst "composer install" aus.';
    return;
}
require_once __DIR__ . '/../common/autoload.php';
define('UPDATE_PATH', __DIR__);
$isManual = is_dir(SW_PATH . '/update-assets');
if ($isManual) {
    define('UPDATE_IS_MANUAL', true);
    define('UPDATE_FILES_PATH', null);
    define('UPDATE_ASSET_PATH', SW_PATH . '/update-assets');
    define('UPDATE_META_FILE', null);
} else {
    define('UPDATE_IS_MANUAL', false);
    define('UPDATE_FILES_PATH', SW_PATH . '/files/update/files');
    define('UPDATE_ASSET_PATH', SW_PATH . '/files/update/update-assets');
    define('UPDATE_META_FILE', SW_PATH . '/files/update/update.json');
}
use Shopware\Recovery\Update\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
if (PHP_SAPI === 'cli') {
    error_reporting(-1);
    ini_set('display_errors', 1);
    $input = new ArgvInput();
    $env = $input->getParameterOption(['--env', '-e'], 'production');
    $application = new Application($env);
    return $application->run($input);
}
$app = (require __DIR__ . '/src/app.php');
$app->run();
예제 #29
0
 /**
  * @dataProvider provideGetParameterOptionValues
  */
 public function testGetParameterOptionEqualSign($argv, $key, $expected)
 {
     $input = new ArgvInput($argv);
     $this->assertEquals($expected, $input->getParameterOption($key), '->getParameterOption() returns the expected value');
 }
예제 #30
0
 /**
  * @return \Symfony\Component\DependencyInjection\ContainerBuilder
  */
 protected function getContainer()
 {
     if ($this->container) {
         return $this->container;
     }
     // Load cli options:
     $input = new ArgvInput();
     $configPath = $input->getParameterOption(['--config', '-c'], $this->getDefaultConfigPath());
     // Build the service container:
     $this->container = ContainerFactory::buildFromConfiguration($configPath);
     return $this->container;
 }