PHP code example of nowise / uup-application

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

    

nowise / uup-application example snippets




declare(strict_types=1);

loWorldAction;
use UUP\Application\Command\ApplicationRunner;

$action = new HelloWorldAction();
$runner = new ApplicationRunner($action);
$runner->execute();


class HelloWorldAction extends ApplicationAction
{
    public function setup(): void
    {
        if ($this->options->isMissing('my-name')) {
            $this->options->setOption('my-name', "Anders");
        }
    }

    public function execute(): void
    {
        if ($this->options->hasOption('my-name')) {
            printf("Hello world, %s!\n", $this->options->getString('my-name'));
        }
    }
}



declare(strict_types=1);

licationAction;
use UUP\Application\Command\ApplicationRunner;

(new ApplicationRunner(new class extends ApplicationAction {

    public function execute(): void
    {
        // TODO: Implement the business logic for script (this method is 

class HelloWorldAction extends ApplicationAction
{
    public function usage(): void
    {
        printf("Sample greeter action class.\n");
        printf("\n");
        printf("Options:\n");
        printf("  my-name:    Set caller name.\n");
        printf("\n");

        parent::usage();
    }

    ...
}

class HelloWorldAction extends ApplicationAction
{
    public function version(): void
    {
        printf("hello-world %s\n", $this->getVersion());
    }

    public function getVersion(): string
    {
        return "1.2.2";
    }

    ...
}