highly extensible, highly enjoyable, BDD testing framework for PHP.


Testing with Peridot is natural. Write tests using the familiar describe-it syntax. Easily and clearly describe how your code should behave in a language that makes sense. See getting started.


Peridot is event driven, so writing plugins or ad hoc extensions is painless. Peridot events and scopes allow you to easily add test helpers, custom reporters, and plugins. WebDriver? Databases? Your framework of choice? No problem. We believe in a small core with endless possibilities.


Peridot is lightweight. Peridot suites load and run faster than similar PHPUnit or phpspec suites. Have slow or bulky integration tests? No problem, Peridot can run your tests concurrently.

Installing Peridot

Peridot can be installed several ways:


# global composer install
$ composer global require peridot-php/peridot

# ensure .composer/vendor/bin is on your PATH
$ export PATH="$PATH:$HOME/.composer/vendor/bin"

# local per project install (recommended)
$ composer require peridot-php/peridot

Manual install

# download the latest phar
$ sudo wget http://peridot-php.github.io/downloads/peridot.phar -O /usr/local/bin/peridot

# or if you prefer curl
$ sudo curl http://peridot-php.github.io/downloads/peridot.phar -o /usr/local/bin/peridot

# make it executable
$ sudo chmod a+x /usr/local/bin/peridot

Manual install (local)

Download Latest Stable Phar

Getting Started

Peridot uses the familiar describe-it syntax to create a clear and readable testing language.

<?php // arrayobject.spec.php
describe('ArrayObject', function() {
    beforeEach(function() {
        $this->arrayObject = new ArrayObject(['one', 'two', 'three']);

    describe('->count()', function() {
        it('should return the number of items', function() {
            $count = $this->arrayObject->count();
            assert($count === 3, 'expected 3');
$ peridot arrayobject.spec.php

      ✓ should return the number of items

  1 passing (19 ms)


$ peridot --help
  peridot [options] [files]

  -f, --focus=FOCUS                  Run tests matching <pattern>
  -s, --skip=SKIP                    Skip tests matching <pattern>
  -g, --grep=GREP                    Run tests with filenames matching <pattern> (default: *.spec.php)
  -b, --bail                         Stop on failure
  -r, --reporter=REPORTER            Select which reporter to use (default: spec)
      --reporters                    List all available reporters
  -C, --no-colors                    Disable output colors
      --force-colors                 Force output colors
  -c, --configuration=CONFIGURATION  A php file containing peridot configuration
  -V, --version                      Display the Peridot version number
  -h, --help                         Display this help message.

-f, --focus

Only run tests whose title matches the provided pattern. See Focusing and Skipping.

-s, --skip

Only run tests whose title does not match the provided pattern. See Focusing and Skipping.

-g, --grep

Only run test files whose filename matches the provided pattern. The default grep pattern is *.spec.php

-b, --bail

Tell peridot to stop running tests as soon as there is a failure.

-r, --reporter

Select which reporter(s) to use (multiple values can be specified). See Specifying Reporters.


List available test reporters.

-C, --no-colors

Disable colors in output.

-c, --configuration

A path to a peridot configuration file. Defaults to getcwd() . '/peridot.php'

Focusing and Skipping

See also Focused Specs, which allow you to focus tests without using command line options.

The --focus and --skip options can be used independently, or combined for complex test isolation. If both are used, --skip will take precedence.

The patterns accepted by both of these options are PCRE regular expressions that are evaluated against the "title" of the test. The test title includes the description of the suite it is contained within, including any ancestors of that suite. For example, the test shown in Getting Started has a title of: ArrayObject ->count() should return the number of items.

If the provided pattern is not a complete PCRE regular expression, it will be surrounded in delimiters. For example, --focus 'foo.*' is equivalent to --focus '~\bfoo.*\b~'. If the provided pattern is not a valid PCRE regular expression, it will be treated as plain text. For example, --focus 'foo(' is equivalent to --focus '~\bfoo\(\b~'. The addition of \b simply prevents accidental matching of substrings.

Specifying Reporters

The --reporter option can be used one or more times, and specifies the name of a reporter to use. Reporter names are registered via ReporterFactory::register.

When multiple reporters are specified, the first reporter specified is the "primary" reporter, and any output generated by this reporter will be displayed as the suite runs. Any subsequent reporters will have their output buffered, and this output will be displayed after the suite has completed.

Example Test Suites

You can head over to the Peridot GitHub organization for plenty of examples using Peridot.

We would love to see other projects using Peridot, so if you have a project that uses it, we would love to know. Feel free to message us and let us know. We will gladly list your project on the site.

Running Peridot's tests

Peridot's tests were written using Peridot. After cloning Peridot, you can run tests using:

$ bin/peridot