https://github.com/stdakov/terminal-request
https://github.com/stdakov/terminal-request
php requests script-php scripts terminal terminal-request
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/stdakov/terminal-request
- Owner: stdakov
- License: apache-2.0
- Created: 2017-03-31T11:24:13.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2019-12-21T15:33:09.000Z (over 6 years ago)
- Last Synced: 2025-01-30T05:26:31.150Z (about 1 year ago)
- Topics: php, requests, script-php, scripts, terminal, terminal-request
- Language: PHP
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# terminalRequest
## Installation
The preferred way to install this tool is through [composer](http://getcomposer.org/download/).
Either run
```
php composer.phar require stdakov/terminal-request
```
or add
```
"stdakov/terminal-request": "*"
```
## Usage
```php
require 'vendor/autoload.php';
```
## Examples
```bash
php script.php command subCommand -a value1 -bc 'value2' --param1 value3 --param2 --pa "value4" --vk value5
```
```php
$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'
Array
(
[a] => value1
[b] => 1
[c] => value2
[param1] => value3
[param2] => 1
[pa] => value4
[vk] => value5
)
```