Create console driven applications powered by PHP

Installs: 18

Dependents: 1

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

0.1.0 2013-09-12 12:17 UTC


Build Status Scrutinizer Quality Score Code Coverage

SpraySole is a PHP library to help create console applications powered by PHP. The API is intended to allow the easy creation of console applications that can be object oriented and cleanly separated.

Project Goals

  • Support the easy creation of console apps powered by PHP following the common use case of: [options] command [arguments]
  • Provide implementations that support the debugging, profiling and analysis of SpraySole driven apps
  • Completely self-contained and should not require any third-party userland libraries that are not bundled with the source
  • Build all components using SOLID, readable and thoroughly unit-tested code


The recommended method for installing SpraySole is through Composer. We're going to assume that you already have Composer installed on your machine and that you can execute it from the command line by typing, you guessed it, composer.

composer require cspray/spraysole:0.1.*

This will install the SpraySole library for you in your current working directory.

If you already have a project you'd like to use SpraySole in you can also adjust your composer.json.

    "require": {
        "cspray/spraysole": "0.1.*"


This is the basic example for kicking off processing and similar to what you'll find in /console.php.


use \SpraySole\BasicApplication;
use \SpraySole\Input\ArgvInput;
use \SpraySole\Output\StreamOutput;

$App = new BasicApplication();

$App->addCommand(new \YourApp\Command\DooHickey());
$App->registerProvider(new \YourApp\Command\FooProvider());

$Input = new ArgvInput($argv);
$StdOut = new StreamOutput(\STDOUT);
$StdErr = new StreamOutput(\STDERR);

// $StdErr is optional and will use $StdOut if not provided
$exitCode = $App->run($Input, $StdOut, $StdErr);



Now, in your console you can execute your app and the commands associated to it. In the example below we'll assume that you have aliased spraysole to execute /install/console.php with PHP.

spraysole --foo bar --bar baz commandname arg1 arg2 arg3