simonepm/argumentor

simple and easy PHP library for passing arguments and options to a PHP command script from command line.

v1.0 2018-10-28 20:59 UTC

This package is auto-updated.

Last update: 2024-09-29 05:02:12 UTC


README

simple and easy PHP library for passing arguments and options to a PHP script from command line.

Installation

composer require simonepm/argumentor

Usage

php example.php testArgument -o testOption

Example

<?php

    require_once "vendor/autoload.php";

    use Simonepm\Argumentor\Command;
    use Simonepm\Argumentor\Argument;
    use Simonepm\Argumentor\Option;

    $command = new Command();

    $command->RegisterArgument("argument");
    $command->RegisterOption("option", "o");

    $command->Exec(function(Argument $argument, Option $option) {

        echo $argument->Get("argument") . PHP_EOL; // "testArgument\n"

        echo $option->Get("option") . PHP_EOL; // "testOption\n"

    });
    
?>