PHP code example of inanepain / console

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

    

inanepain / console example snippets




$router = new ConsoleRouter($argv);
$router->register(AppCommands::class);
exit($router->run());
----

.Make it executable:
[source,bash]
----
chmod +x console.php
----

:leveloffset!:

<<<

:leveloffset: +1

= Quick Start

== Your First Command

Create a simple command that greets a user:

[source,php]
----


class HelloCommands
{
    #[Command('hello', 'Say hello to someone')]
    public function hello(
        #[Argument('Name of the person to greet')]
        string $name
    ): int {
        echo "Hello, {$name}!" . PHP_EOL;
        return 0;
    }