1. Go to this page and download the library: Download sitphp/commands 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/ */
sitphp / commands example snippets
namespace App\Commands;
class YourCommand extends \SitPHP\Commands\Command {
function handle(){
$this->write('hello');
}
}
namespace App\Commands;
class YourCommand extends \SitPHP\Commands\Command {
function handle(){
$this->write('Hello,');
// Single line break
$this->lineBreak();
$this->write('I am ');
$this->write('Alex');
// Double line break
$this->lineBreak(2);
$this->write('I code with PHP');
}
}
// In your command class ...
function prepare()
{
// Register "name" argument at position "0"
$this->setArgumentInfos('name', 0);
// Register "color" option
$this->setOptionInfos('color');
}
function handle()
{
// Retrieve name argument value
$name = $this->getArgument('name');
if ($name === null) {
throw new \Exception('The "name" argument is
// In the "handle" method of your command class ...
$this->writeLn('This will display in <cs color="blue">blue</cs>');
$this->writeLn('This will display <cs style="bold;highlight">highlighted and bold</cs>');
$this->writeLn('This will display <cs color="white" background-color="blue">with a white text in a blue background</cs>');
// In the "handle" method of your command class ...
$this->bloc('I am a simple bloc ...')
->display();
// In the "handle" method of your command class ...
// Create a 5 steps progress bar
$progress_bar = $this->progressBar(5)
->placeHere()
->display();
for($i = 1; $i <= 5; $i++){
sleep(1);
$progress_bar->progress();
}
// In the "handle" method of your command class ...
function handle(){
$genres = ['pop', 'rock', 'hip hop', 'classical'];
$genre = $this->question('Which music genre do you like ?', $genres)
->ask();
$this->lineBreak();
$this->writeLn('Your favorite music genre is : '.$genre);
}
// In the "handle" method of your command class ...
function handle(){
$choices = ['red', 'blue', 'green'];
$color_index = $this->choice($choices, 'Which color do you like best ?', 'Colors')
->enableQuit()
->ask();
if($color_index !== null){
$this->lineBreak();
$this->writeLn('You like the '.$choices[$color_index].' color the best');
}
}
// In the "handle" method of your command class ...
$this->writeLn('This goes before');
$section = $this->section()->placeHere();
$this->writeLn('This goes after');
$section->writeLn('This goes in the <cs color="blue">middle</cs>');
sleep(1);
$section->overwriteLn('This goes in the <cs color="red">middle</cs>');
// In the "handle" method of your command class ...
$this->table([
['<cs style="bold">Animal</cs>', '<cs style="bold">Classification</cs>'],
'line',
['elephant', 'mammal'],
['parrot', 'bird']
])->display();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.