/pop

Parameter Options Parser (pop) is a simple argument parser from a string for PHP

Primary LanguagePHP

Parameter Option Parser Lib

POP (Parameter Option Parser) can parse options and values from a string

Install by ppm

ppm --install="<alias>@github/intellivoid/pop" --branch="production" --fix-conflict

Build and install locally

make clean build
sudo make install

CLI Example

$ ./example/bin-cli -h 127.0.0.1 -u=user -p passwd --debug --max-size=3 test
Array
(
    [h] => 127.0.0.1
    [u] => user
    [p] => passwd
    [debug] => 1
    [max-size] => 3
    [test] => 1
)

Example

<?php
/** @noinspection PhpIncludeInspection */
require("ppm");

ppm\ppm::import("net.intellivoid.pop");

$string = '-h 127.0.0.1 -u=user -p passwd --debug --max-size=3 test';
print_r(pop\pop::parse($string));

Output:

Array
(
    [h] => 127.0.0.1
    [u] => user
    [p] => passwd
    [debug] => 1
    [max-size] => 3
    [test] => 1
)