PHP code example of hoathis / symfony-console-bridge
1. Go to this page and download the library: Download hoathis/symfony-console-bridge library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hoathis / symfony-console-bridge example snippets
$app = new Application();
$app
->register('output:verbosity')
->setCode(function(InputInterface $input, OutputInterface $output) {
$output->writeln('<info>I\'m a decorated text only in the console</info>');
if ($output->getVerbosity() === OutputInterface::VERBOSITY_NORMAL) {
$output->writeln('I\'ll be displayed with the <comment>normal</comment> verbosity level');
}
if ($output->getVerbosity() === OutputInterface::VERBOSITY_VERBOSE) {
$output->writeln('I\'ll be displayed with the <comment>verbose</comment> verbosity level');
}
if ($output->getVerbosity() === OutputInterface::VERBOSITY_VERY_VERBOSE) {
$output->writeln('I\'ll be displayed with the <comment>very verbose</comment> verbosity level');
}
if ($output->getVerbosity() === OutputInterface::VERBOSITY_DEBUG) {
$output->writeln('I\'ll be displayed with the <comment>debug</comment> verbosity level');
}
})
;
class Application extends BaseApplication
{
protected function configureIO(InputInterface $input, OutputInterface $output)
{
parent::configureIO($input, $output);
$formatter = $output->getFormatter();
$formatter->setStyle('info', new OutputFormatterStyle('#e4cbf4'));
$formatter->setStyle('comment', new OutputFormatterStyle('#795290'));
$formatter->setStyle('question', new OutputFormatterStyle('#de8300'));
$formatter->setStyle('error', new OutputFormatterStyle('white', '#ff3333', array(OutputFormatterStyle::STYLE_BOLD)));
}
//...
}
$app = new Application();
$app
->register('helper:window:animate')
->setCode(function(InputInterface $input, OutputInterface $output) use ($app) {
$window = $app->getHelperSet()->get('window');
$output->writeln('<info>I\'m going to bring your window to the foreground and back to the foreground after one second</info>');
sleep(1);
$window->lower($output);
sleep(1);
$window->raise($output);
$output->writeln('<info>I\'m going to minimize your window and restore it after one second</info>');
sleep(1);
$window->minimize($output);
sleep(1);
$window->restore($output);
})
;