PHP code example of f-oris / easy-console

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

    

f-oris / easy-console example snippets




namespace Demo\Console;

/**
 * Class Application
 */
class Application extends \Foris\Easy\Console\Application
{
    /**
     * Register the commands for the application.
     *
     * @throws \ReflectionException
     */
    protected function commands()
    {
        parent::commands();
        $this->load(__DIR__ . '/Commands');
    }
}

#!/usr/bin/env php


\Application(__DIR__);

$app->run();



namespace Foris\Easy\Console\Demo\Commands;

use Foris\Easy\Console\Commands\Command;

/**
 * Class HelloCommand
 */
class HelloCommand extends Command
{
    /**
     * Command name
     * 
     * @var string 
     */
    protected $name = 'hello';
    
    /**
     * Command description 
     * 
     * @var string 
     */
    protected $description = 'This is a demo command.';
    
    /**
     * Execute the console command.
     */
    protected function handle()
    {
        $this->line('Hello world');
    }
}
bash
php artisan make:command HelloCommand