PHP code example of elaberino / symfony-style-verbose
1. Go to this page and download the library: Download elaberino/symfony-style-verbose 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/ */
elaberino / symfony-style-verbose example snippets
$io = new SymfonyStyle($input, $output);
try {
if ($output->isVerbose()) {
$io->title('This is my title');
$io->section('This is my section');
}
//do some stuff here
if ($output->isVerbose()) {
$io->section('Get objects');
$io->progressStart(count($objects));
}
$objects = $this->repository->findBy(['active' => true]);
foreach ($objects as $object) {
//do something with the object
if ($output->isVerbose()) {
$io->progressAdvance();
}
}
if ($output->isVerbose()) {
$io->progressFinish();
$io->success('All objects handled');
}
} catch (Throwable $throwable) {
if ($output->isVerbose()) {
$io->error('Error while handling products');
}
return Command::FAILURE;
}
return Command::SUCCESS;
$io = new SymfonyStyleVerbose($input, $output);
try {
$io->titleIfVerbose('This is my title');
$io->sectionIfVerbose('This is my section');
//do some stuff here
$io->sectionIfVerbose('Get objects');
$io->progressStartIfVerbose(count($objects));
$objects = $this->repository->findBy(['active' => true]);
foreach ($objects as $object) {
//do something with the object
$io->progressAdvanceIfVerbose();
}
$io->progressFinishIfVerbose();
$io->successIfVerbose('All objects handled');
} catch (Throwable $throwable) {
$io->errorIfVerbose($throwable->getMessage());
return Command::FAILURE;
}
return Command::SUCCESS;