Download the PHP package weew/console-arguments without Composer

On this page you can find all versions of the php package weew/console-arguments. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package console-arguments

Console arguments parser

Build Status Code Quality Test Coverage Version Licence

Table of contents

Installation

composer require weew/console-arguments

Introduction

This package allows you to easily build commands with certain expectations and then match them against a set of console arguments. It consists of two major parts, a ArgumentsParser and ArgumentsMatcher.

Note: this package has not been tested on windows.

Parsing arguments

Arguments parser allows you to parse console arguments and takes care of many annoying things like quotes, equitation signs, combined flags etc. The parsing process consists of two steps. The first step is all about normalization and separation of arguments into pieces. The second one is for grouping of flags and options. Lets take a look at this example:

Now you can groups these arguments.

Depending on what kind of arguments you're working with, you might need grouped or ungrouped arguments to extract all the necessary information.

If your arguments are in form of an array instead of a string, simply do implode(' ', $args). Be careful with the $argv arguments. First value in there is the path of the script and you need to remove it array_unshift($args).

Matching arguments

So now you have arguments. But working with plain arrays, ensuring that certain values are set etc. is quite annoying. Lets make it easy.

You can also create arguments and options like this.

There are several kinds of arguments and options.

As soon as you have some commands defined, you can match them against the arguments. Matcher will throw exceptions if command expectations were not matched.

If you have multiple commands and don't know which should be used, you can let the matcher find it based on the command name. First value inside the arguments array is assumed to be a command name. Command name is matched intelligently. So a command with name command will match command as well as c and com. If multiple commands qualify for the same name, an exceptions will be thrown.

You can also match only an option or an argument the same way, just use matchArgument and matchOption methods.

Strict mode

By default, arguments matcher runs in strict mode. This means that if a command receives to many arguments or unknown options, an exception will be thrown. This behaviour can be disabled though.


All versions of console-arguments with dependencies

PHP Build Version
Package Version
Requires weew/helpers-string Version ^1.7
weew/helpers-array Version ^1.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package weew/console-arguments contains the following files

Loading the files please wait ....