GitHub Repository

apiato

Definition

Commands:

Principles

Rules

Folder Structure

 - app
    - Containers
        - {container-name}
            - UI
                - CLI
                    - Commands
                        - SayHelloCommand.php
                        - ...
    - Ship
        - Commands
            - GeneralCommand.php
            - ...

Code Samples

Example: a simple Command

<?php

namespace App\Containers\Welcome\UI\CLI\Commands;

use App\Ship\Parents\Commands\ConsoleCommand;

/**
 * Class SayWelcomeCommand
 *
 * @author  Mahmoud Zalt  <mahmoud@zalt.me>
 */
class SayWelcomeCommand extends ConsoleCommand
{

    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'apiato:welcome';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Just saying Welcome.';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return void
     */
    public function handle()
    {
        $this->info('Welcome to apiato :)'); // green color
        // $this->line('Welcome to apiato :)'); // normal color
    }
}

Usage from CLI (Terminal):

php artisan apiato:welcome

Schedule Commands Execution

To Schedule the execution of a Command checkout the Tasks Scheduling page.

Define Consoles Routes

To define Console route go to app/Ship/Commands/Routes.php.