Giter Site home page Giter Site logo

jeffersoncechinel / app-console Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yiisoft/app-console

0.0 0.0 0.0 33 KB

Yii3 console application

Home Page: https://www.yiiframework.com

License: BSD 3-Clause "New" or "Revised" License

PHP 98.39% Batchfile 1.61%

app-console's Introduction

Yii app console


Latest Stable Version Total Downloads Build status Scrutinizer Code Quality Code Coverage static analysis type-coverage

The package is a console application that can be used to perform common tasks in a Yii application.

Requirements

  • PHP 8.0 or higher.

Installation

The package could be installed with composer:

composer create-project --prefer-dist --stability=dev yiisoft/app-console <your project>

General usage

Create command console

<?php

declare(strict_types=1);

namespace App\Console;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Yiisoft\Yii\Console\ExitCode;

final class Hello extends Command
{
    protected static $defaultName = 'hello';
    protected static $defaultDescription = 'An example command';

    private string $sentence = 'sentence';

    public function __construct()
    {
        parent::__construct();
    }

    protected function configure(): void
    {
        $this->setDefinition(
            new InputDefinition([
                new InputArgument($this->sentence, InputArgument::OPTIONAL, 'Sentence to say.', 'Hello!'),
            ])
        );
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $output->writeln("You says: {$input->getArgument('sentence')}");

        return ExitCode::OK;
    }
}

Using command console

$ ./yii
Yii Console 1.0

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display help for the given command. When no command is given display help for the list command
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi|--no-ansi  Force (or disable --no-ansi) ANSI output
  -n, --no-interaction  Do not ask any interactive question
      --config=CONFIG   Set alternative configuration name
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  completion  Dump the shell completion script
  hello       An example command
  help        Display help for a command
  list        List commands
  serve       Runs PHP built-in web server
$ ./yii hello
You says: Hello!

$ ./yii hello 'Code something'
You says: Code something

Testing

Unit testing

The template comes with ready to use Codeception configuration. In order to execute tests run:

vendor/bin/codecept run

Static analysis

The code is statically analyzed with Psalm. To run static analysis:

./vendor/bin/psalm

License

The Yii app console is free software. It is released under the terms of the BSD License. Please see LICENSE for more information.

Maintained by Yii Software.

Support the project

Open Collective

Follow updates

Official website Twitter Telegram Facebook Slack

app-console's People

Contributors

dependabot[bot] avatar samdark avatar stylecibot avatar terabytesoftw avatar tomaszkane avatar vjik avatar xepozz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.