1. Go to this page and download the library: Download zachleigh/artisanize 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/ */
zachleigh / artisanize example snippets
use Artisanize\Command;
class MyCommand extends Command
{
/**
* The command signature.
*
* @var string
*/
protected $signature = 'signature';
/**
* The command description.
*
* @var string
*/
protected $description = 'Description.';
/**
* Handle the command.
*/
protected function handle()
{
// Handle your command
}
}
use Artisanize\Command;
class ExampleCommand extends Command
{
/**
* The command signature.
*
* @var string
*/
protected $signature = 'namespace:name {argument} {--o|option=default}';
/**
* The command description.
*
* @var string
*/
protected $description = 'Command decription.';
/**
* Handle the command.
*/
protected function handle()
{
// handle the command
}
}
if ($this->confirm('Do you wish to continue? ')) {
// user answered true
}
$name = $this->ask('What is your name?', 'Nobody');
$password = $this->askPassword('Please type your password');
$car = $this->choose('What is your favourite car?', ['Ferrari', 'Lamborghini', 'Maserati'], 1);
$food = $this->anticipate('What is your favourite food?', ['Pizza', 'Pasta', 'Lasagna'], 'Mozzarella');
$colors = $this->choice('What are your favourite colors (defaults to blue and red)?', ['Blue', 'Red', 'Green'], '0,1');
protected function handle()
{
$this->output->write('Message'); // plain text
$this->output->writeInfo('Message'); // green text
$this->output->writeError('Message'); // red text
$this->output->writeComment('Message'); // yellow text
}
protected function handle()
{
$output = $this->getOutputInterface(); // $output is instance of Symfony\Component\Console\Output\OutputInterface
}