Download the PHP package wildphp/command-parser without Composer

On this page you can find all versions of the php package wildphp/command-parser. 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 command-parser

Command parsing library for WildPHP


Build Status Scrutinizer Code Quality Scrutinizer Code Coverage Latest Stable Version Latest Unstable Version Total Downloads

This library aims at making command parsing easy. Not only does it parse strings into commands and parameters, it allows you to define restrictions to parameters (so-called strategies) and do automatic type/content validation.

Installation

To install this library, you will need Composer.

$ composer require wildphp/command-parser ^0.1

Getting started

This library comes with a set of ready-to-use parameters, but you might want to develop your own. More on that later.

The most important classes in the library are the Command, ParameterStrategy, CommandParser and CommandProcessor.

Command

This is the class which defines your commands. It is a storage class, meaning it does nothing more but store items you hand to it.

Creating a Command

A Command takes two parameters for its constructor. A callback which should be called when the command is triggered, and one or more ParameterStrategy instances which will define the behavior of the command. For example:

ParameterStrategy

A ParameterStrategy instance describes the ways in which commands may be executed.

Its constructor takes a few arguments:

Available parameters

NumericParameter

Takes any value which is numeric, it uses the php is_numeric function internally.

PredefinedStringParameter

Set a predefined string in its constructor and only that string will be accepted as its value, thus any other value will be rejected.

StringParameter

Returns true under any circumstance, since parameters are always strings.

CommandParser

As the name would suggest, this is the class in charge of actually parsing messages. When it does so, it hands out ParsedCommand objects. As it is a utility class, its methods are called statically.

findApplicableStrategy

findApplicableStrategy(Command $commandObject, array $parameters): ParameterStrategy

This method finds the most applicable strategy to use on $parameters and returns it.

parseFromString

parseFromString(string $string, string $prefix = '!'): ParsedCommand

Parses a command and its parameters from a string, but does not process them. See below for the CommandProcessor. Set $prefix for the prefix to use, which should prefix any command given.

ParsedCommand is an object containing the command name and the original parameters given.

CommandProcessor

This class processes a ParsedCommand further and provides the value conversion facilities. Moreover, when instantiated, it acts as a storage facility for commands so they need not be stored elsewhere.

processParsedCommand

The heart of this class is this static function.

public static function processParsedCommand(ParsedCommand $parsedCommand, Command $command): ProcessedCommand

It takes a ParsedCommand object and accompanying Command object and processes it into a ProcessedCommand object, which contains the original ParsedCommand data plus the callback, the converted parameter values and also the applied strategy used for conversion.

process

process(ParsedCommand $parsedCommand): ProcessedCommand

Much the same as the above function but uses the internal command collection.

registerCommand

registerCommand(string $command, Command $commandObject): bool

Adds a command to the internal command collection, identified by $command. Returns true on success, false if the given identifier already exists.

findCommand

findCommand(string $command): Command

Returns a Command object added by above function which is identified by $command.

Contributors

You can see the full list of contributors in the GitHub repository.


All versions of command-parser with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
yoshi2889/validation-closures Version ^0.2
yoshi2889/collections Version ^0.1
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 wildphp/command-parser contains the following files

Loading the files please wait ....