PHP code example of siims / clp

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

    

siims / clp example snippets


php Example1.php --help hello='her is my world'
--> may not work as expected
php Example1.php --help hello="'her is my world'"
--> may work as expected

The package also does not support something like
php Example1.php -file Example2.php
--> will not work as expected


/* License: OSL-3.0
   To be launched in shell environment
   php Example1.php
*/

       "hello" => "callHello"
    ],
    "flags" => [
        "try-run","verbose","debug"
    ],
    "values" => [
        "hello" => "world"
    ],
    "events" => [
        "onAfterProcess" => "parsingCommandLineFinished",
        "onNoOptions" => "displayHelp"
    ]
    ];

$hello = new clp($argv,$options);

function displayHelp() {
    global $argv;
    echo "$argv[0] hello=\"your_name\" | --h | -help | verbose | debug\n";
}

function parsingCommandLineFinished($config) {
    echo "Finished parsing command line.\n";
    print_r($config);
}

function callHello($config,$method) {
    echo "Hello {$config["values"]["hello"]}\n";
    echo "Implemented by $method\n";
}