symfony command 应用

2019-03-18 16:05:26 阅读:26 编辑
<?PHP
set_time_limit (0);
INI_set ('memory_limit','1024 M');

function includeIfExists ($file)
{if (file_exists ($file)) {return include $file;}
}

if ((!$loader = includeIfExists (__DIR__ . '/../vendor/autoload.php')) && (!$loader = includeIfExists (__DIR__ . '/../../../autoload.php'))) {print ('You must set up the project dependencies using Composer before you can use Satis.');
    exit (1);
}

$arguments = ['command' => 'build',
     'file'    => __DIR__.'/../satis.json',
     'output-dir'  => __DIR__."/",
];
//$output = new \Symfony\Component\Console\Output\ConsoleOutput ();
$output = new \Symfony\Component\Console\Output\BufferedOutput ();
$input = new \Symfony\Component\Console\Input\ArrayInput ($arguments);
$application = new Composer\Satis\Console\Application ();
$application->setAutoExit (false);
$returnCode = $application->run ($input, $output);
if ($returnCode != 0) {$outputText = $output->fetch ();
    var_dump ($outputText);
}else{var_dump ($returnCode);
}