1. Go to this page and download the library: Download krisanalfa/konsole 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/ */
krisanalfa / konsole example snippets
namespace Konsole\Commands;
use Konsole\Command;
class SendEmails extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = '';
/**
* The console command description.
*
* @var string
*/
protected $description = '';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
}
}
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'email:send {user}';
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'email:send
{user : The ID of the user}
{--pretending= : Whether the job should be prentended}';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$userId = $this->argument('user');
//
}
$arguments = $this->argument();
// Retrieve a specific option...
$isPretending = ($this->option('pretending') !== null);
// Retrieve all options...
$options = $this->option();
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$name = $this->ask('What is your name?');
}
$password = $this->secret('What is the password?');
// The default answer is 'no|N'
if ($this->confirm('Do you wish to continue? [y|N]')) {
// Do something if user answer 'yes|y'
}
$name = $this->anticipate('What is your name?', ['Alfa', 'Fitria']);
$name = $this->choice('What is your name?', ['Alfa', 'Fitria'], $default);
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->info('Display this on the screen');
}
$this->warn('Something went wrong!');
$this->error('Something went wrong!');
$this->line('Display this on the screen');
$this->suggest('Better you pick Sven, because you have Magnus on your side.');