sepiphy/console

Extend Symfony Console within a few utilities

v0.11.0 2021-04-06 03:23 UTC

This package is auto-updated.

Last update: 2021-04-06 03:25:12 UTC


README

Packagist Packagist Version GitHub

Installation

Install sepiphy/console package via composer.

$ composer require sepiphy/console

Usage

#!/usr/bin/env php
<?php

namespace Acme;

require __DIR__ . '/vendor/autoload.php';

use Sepiphy\Console\Application as SepiphyApplication;
use Sepiphy\Console\Command as SepiphyCommand;

class HelloCommand extends SepiphyCommand
{
    protected function configure()
    {
        $this->setName('hello');
        $this->setDescription('Just say hello to you');
        $this->addArgument('name');
    }

    protected function fire()
    {
        $this->output->line('Hello '.$name = $this->input->getArgument('name') ?? 'You');

        $this->output->comment('This is a comment message.');
        $this->output->success('This is a success message.');
        $this->output->error('This is an error message.');
        $this->output->warning('This is a warning message.');
        $this->output->note('This is a note message.');
        $this->output->caution('This is a caution message.');

        $this->container->get('foo-id'); // 'foo-instance'
    }
}

$application = new \Sepiphy\Console\Application();
$application->set('foo-id', 'foo-instance');
$application->add(new HelloCommand());
$application->run();