PHP code example of net_bazzline / php_component_cli_environment
1. Go to this page and download the library: Download net_bazzline/php_component_cli_environment 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/ */
net_bazzline / php_component_cli_environment example snippets
#open bin/hello
#replace line "$usage = basename(__FILE__) . ' [-v|--verbose]';" with the line below
$usage = basename(__FILE__) . ' <your name> [-v|--verbose]';
#replace the line "//put in your business logic" with the code below
//begin of dependencies
$arguments = $environment->getArguments();
$values = $arguments->getValues();
//end of dependencies
//begin of argument validation
$valuesNotAreValid = (count($values) == 0);
if ($valuesNotAreValid) {
throw new InvalidArgumentException(
'invalid number of arguments provided'
);
}
//end of argument validation
//begin of business logic
$name = ucfirst($values[0]);
$environment->outputIfVerbosityIsEnabled('provided values are: ' . implode(' ', $values));
$environment->output('Hello ' . $name);
//end of business logic
#execute ./bin/hello world
mkdir -p vendor/net_bazzline/php_component_cli_environment
cd vendor/net_bazzline/php_component_cli_environment
git clone https://github.com/bazzline/php_component_cli_environment .
composer