PHP code example of jet / console

1. Go to this page and download the library: Download jet/console 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/ */

    

jet / console example snippets




namespace Your\Namespace;

use Jet\Console\Command\AbstractCommand;

class ExampleCommand extends AbstractCommand
{
    public function init()
    {
        $this
            ->setName('example')
            ->setDescription('An example command')
            ->addArgument('hello', Argument::OPTIONAL, null, 'description');
    }

    public function execute()
    {
        if ($this->hasArgument('hello')) {
            return $this->someMethod();
        }

        $this->display('No argument found');
    }

    public function someMethod()
    {
        $argument = $this->getArgument('hello');
        $this->display("hello {$argument}");
    }
}

#!/usr/bin/env php


///../autoload.dist.php';

Use Jet\Console\Console;
Use Your\Namespace;

$console = new Console('name', 'version');
$console->addCommand(new ExampleCommand);
$console->run();