Download the PHP package treffynnon/command-wrap without Composer

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

Command Wrap

A PHP library to wrap the command line/terminal/shell. It provides a clean builder that escapes arguments and commands - you can extract a command string to run as you please or pass the builder to a runner.

Installation

Example

Using a callback to process output

Each line of the command's output can be processed by a callback/anonymous/lambda function. You can of course pass in a closure too!

This would replace all tabs with four (4) spaces in each line of output from the command. Note that the new value must be returned from your lambda.

You can then get the output in the usual way by calling $response->getOutput().

If you want to have updates in real time from long running command then you need to use the SymfonyProcess runner and log/echo from your custom callback function.

Getting a command as a string

Available command line types

Type Builder method Example final output
Command addCommand('ls'); ls
Flag addFlag('-t'); -t
Flag addFlag('-t', '/tmp'); -t='/tmp'
Argument addArgument('results'); --results
Argument addArgument('results', '/tmp/results.log'); --results='/tmp/results.log'
Parameter addParameter('parameter'); 'parameter'
EnvVar addEnvVar('MY_ENV_VAR', 'value'); MY_ENV_VAR='value'
Raw addRaw('> /dev/null 2>&1') > /dev/null 2>&1

Note: As the name implies Raw does not perform any escaping - use with appropriate caution.

Available runners

By implementing Treffynnon\CommandWrap\Runners\RunnerInterface you can also provide your own custom runner.

When a command is executed via a runner it will return an instance of \Treffynnon\CommandWrap\Response containing the response from STDOUT and STDERR if available.

Command combinators

POSIX commands can be combined with a few characters such as:

These have been wrapped up into objects that you can use to combine commands/builders. You can also combine combinators too!

These can then be passed to a runner just like any builder can be:

Command assemblers

When a command is being converted into a string an assembler will be used by default it will use the ChronoAssembler, but you can also use OrderedAssembler or even provide your own by implementing AssemblerInterface.

ChronoAssembler compiles a command in the order it was added to the builder (chronologically). OrderedAssembler combines into a specified order - see the class for details.

To specify the assembler to use you provide an instance of it to the Builder object.

Custom command collection

It is also possible to provide your own command collection class as the second parameter to your Builder instance.

Again implement the CommandCollectionInterface.

Tests

Unit testing is completed with phpspec, integration testing with phpunit and the code is also linted with php -l, phpcs and phpcpd. To run the tests you can use the following composer command:

Licence

BSD 3 clause licence - see LICENCE.md.


All versions of command-wrap with dependencies

PHP Build Version
Package Version
Requires php Version >5.6
symfony/process Version ^3.0
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 treffynnon/command-wrap contains the following files

Loading the files please wait ....