Fork me on GitHub

Getting Started


  • PHP 5.5+
  • phpdbg or Xdebug (only required for code coverage analysis)


The recommended way to install Kahlan is with Composer as a development dependency of your project.

composer require --dev kahlan/kahlan

Alternatively, you may manually add "kahlan/kahlan": "~4.0" to the require-dev dependencies within your composer.json.

The Kahlan package is installed with a vendor library and its binary accessible through vendor/bin/kahlan by default. However, you can configure its location like all other composer vendor binaries.

Running Kahlan

Once Kahlan is installed, you can run your tests (referred to as specs) with:


For a full list of the options, see the CLI Options.

Directory Structure

The recommended directory structure is to add a spec directory at the top level of your project. You may then place your Spec files within this directory. Spec files should have a .spec.php or Spec.php suffix. The spec directory should mirror the structure of your source code directory.

An example directory structure would be:

├── spec                       # The directory containing your specs
│   └── ClassA.spec.php
│   └── subdir
│       └── ClassB.spec.php
├── src                        # The directory containing your source code
│   └── ClassA.php
│   └── subdir
│       └── ClassB.php
├── composer.json

For basic, you can clone to get started.