Skip to content

Instantly share code, notes, and snippets.

<?php
$this->io->error('Lorem ipsum dolor sit amet');
// or with array:
$this->io->error([
'Lorem ipsum dolor sit amet',
'Consectetur adipiscing elit',
]);
<?php
$this->io->warning('Lorem ipsum dolor sit amet');
// or with array:
$this->io->warning([
'Lorem ipsum dolor sit amet',
'Consectetur adipiscing elit',
]);
<?php
$this->io->success('Lorem ipsum dolor sit amet');
// or with array:
$this->io->success([
'Lorem ipsum dolor sit amet',
'Consectetur adipiscing elit',
]);
<?php
$this->io->choice('Select the queue to analyze', ['queue1', 'queue2', 'queue3']);
// default value:
$this->io->choice('Select the queue to analyze', ['queue1', 'queue2', 'queue3'], 'queue1');
<?php
$this->io->confirm('Restart the web server?');
// default value:
$this->io->confirm('Restart the web server?', true);
<?php
$this->io->askHidden('What is your password?');
// validation:
$this->io->askHidden('What is your password?', function ($password) {
if (empty($password)) {
throw new \RuntimeException('Password cannot be empty.');
}
return $password;
<?php
$this->io->ask('What is your name?');
// default value:
$this->io->ask('Where are you from?', 'United States');
// validation:
$this->io->ask('Number of workers to start', 1, function ($number) {
if (!is_numeric($number)) {
throw new \RuntimeException('You must type a number.');
<?php
// use simple strings for short caution message
$this->io->caution('Lorem ipsum dolor sit amet');
// consider using arrays when displaying long caution messages
$this->io->caution([
'Lorem ipsum dolor sit amet',
'Consectetur adipiscing elit',
'Aenean sit amet arcu vitae sem faucibus porta',
]);
<?php
// use simple strings for short notes
$this->io->note('Lorem ipsum dolor sit amet');
// consider using arrays when displaying long notes
$this->io->note([
'Lorem ipsum dolor sit amet',
'Consectetur adipiscing elit',
'Aenean sit amet arcu vitae sem faucibus porta',
]);
<?php
// outputs three consecutive blank lines
$this->io->text('Line 02-01');
$this->io->newLine(3);
$this->io->text('Line 02-02');