stdakov / terminal-request
Powerful tool for commands
v1.2
2019-12-21 15:27 UTC
Requires
- php: >=5.4.0
This package is auto-updated.
Last update: 2024-12-22 02:01:27 UTC
README
Installation
The preferred way to install this tool is through composer.
Either run
php composer.phar require stdakov/terminal-request
or add
"stdakov/terminal-request": "*"
Usage
require 'vendor/autoload.php';
Examples
php script.php command subCommand -a value1 -bc 'value2' --param1 value3 --param2 --pa "value4" --vk value5
$terminal = new Terminal\Request(); echo "Script:" . $terminal->getScript() . PHP_EOL; echo "Command:" . $terminal->getCommand() . PHP_EOL; echo "SubCommand:" . $terminal->getSubCommand() . PHP_EOL; foreach ($terminal->getParams() as $paramName => $paramValue) { echo "Param $paramName has value '" . ($terminal->getParameter($paramName) === true ? "true" : $terminal->getParameter($paramName)) . "'" . PHP_EOL; } print_r($terminal->getParams());
Output
Script:script.php
Command:command
SubCommand:subCommand
Param a has value 'value1'
Param b has value 'true'
Param c has value 'value2'
Param param1 has value 'value3'
Param param2 has value 'true'
Param pa has value 'value4'
Param vk has value 'value5'
<pre>Array
(
[a] => value1
[b] => 1
[c] => value2
[param1] => value3
[param2] => 1
[pa] => value4
[vk] => value5
)