PHPackages                             deminy/behat-rest-testing - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. deminy/behat-rest-testing

AbandonedArchivedLibrary[HTTP &amp; Networking](/categories/http)

deminy/behat-rest-testing
=========================

Demo on doing feature tests with Behat 3 and how to start writing feature tests for REST APIs.

3.0.2(7y ago)7720.8k13MITPHPPHP &gt;=5.4.0

Since Dec 9Pushed 7y ago4 watchersCompare

[ Source](https://github.com/deminy/behat-rest-testing)[ Packagist](https://packagist.org/packages/deminy/behat-rest-testing)[ RSS](/packages/deminy-behat-rest-testing/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (3)Versions (9)Used By (0)

Summary
=======

[](#summary)

[![Build Status](https://camo.githubusercontent.com/b2d25a683fd61949995b85043e985d75f99fecdb8cfb070b9366424f01fe6637/68747470733a2f2f7472617669732d63692e6f72672f64656d696e792f62656861742d726573742d74657374696e672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/deminy/behat-rest-testing)[![Latest Stable Version](https://camo.githubusercontent.com/65c29c66736b21381bf56b065726fce2439cb1deb8c17a1873edbad0c983e8fa/68747470733a2f2f706f7365722e707567782e6f72672f64656d696e792f62656861742d726573742d74657374696e672f762f737461626c652e737667)](https://packagist.org/packages/deminy/behat-rest-testing)[![Latest Unstable Version](https://camo.githubusercontent.com/05ddc5ca9af9bad3f504a413da924d1755c9d5111e9c42d9373f95b0e1b94550/68747470733a2f2f706f7365722e707567782e6f72672f64656d696e792f62656861742d726573742d74657374696e672f762f756e737461626c652e737667)](https://packagist.org/packages/deminy/behat-rest-testing)[![License](https://camo.githubusercontent.com/afdf5f909f9f10c4c930daff31b9438ff6a1c1b822ab1e46e9a1ea7dcd640e87/68747470733a2f2f706f7365722e707567782e6f72672f64656d696e792f62656861742d726573742d74657374696e672f6c6963656e73652e737667)](https://packagist.org/packages/deminy/behat-rest-testing)

This repo is to help developers to easily understand how to do feature tests with Behat, and to start writing feature tests for REST APIs, with following features included:

- Core contexts/steps for testing REST APIs.
- Sample RESTful services, and sample feature tests against the services.
- Best of all: To start writing feature tests for the project you are working on, you may use this repo in your project via *Composer* if you happen to use *Composer* to manage 3rd-party libraries.

**NOTE**: Following instructions focus on Behat 3.0.6+ and PHP 5.4+. If you use Behat 2.x and/or PHP 5.3 (5.3.3+), please check branch "[1.x](https://github.com/deminy/behat-rest-testing/tree/1.x)" for details.

Dependencies
============

[](#dependencies)

Branch master
-------------

[](#branch-master)

- [PHP](http://www.php.net) 5.4+
- [Behat](https://github.com/Behat/Behat) 3.0.6 to 3.3.x
- [Behat Web API Extension](https://github.com/Behat/WebApiExtension)

Branch 1.x (old releases for Behat 2.x)
---------------------------------------

[](#branch-1x-old-releases-for-behat-2x)

- [PHP](http://www.php.net) 5.3.3+
- [Behat](https://github.com/Behat/Behat) &gt;=2.4.0, &lt;=3.0.0.

Installation - Source
=====================

[](#installation---source)

You will need to download *Composer* and run the install command under the same directory where the 'composer.json' file is located:

```
curl -s http://getcomposer.org/installer | php && ./composer.phar install
```

Installation - Composer
=======================

[](#installation---composer)

You may also install using [Composer](https://github.com/composer/composer) if you want to use this repo in your own project.

Step 1. Add the repo as a dependency.

```
"require": {
    "deminy/behat-rest-testing": "~3.0.0"
}
```

**NOTE**: This is for running with Behat 3 only. If you use Behat 2.x, please check [installation instructions for v1.x](https://github.com/deminy/behat-rest-testing/blob/1.x/README.md) for details.

Step 2. Run Composer: `php composer.phar install`.

How to Test
===========

[](#how-to-test)

1. Set up and run REST API server.
----------------------------------

[](#1-set-up-and-run-rest-api-server)

You can have a virtual host set up under Apache, with DocumentRoot set to "www/" of this repo and DirectoryIndex set to "router.php". Please make sure that module mod\_rewrite is enabled, otherwise the REST server won't be able to handle requests properly. You may also need to update option "base\_url" in the configuration file "behat.yml".

Alternatively, you may consider to use the [PHP 5.4+ built-in web server](http://php.net/manual/en/features.commandline.webserver.php).

To start the REST API server using PHP 5.4+ built-in web server, please run command similar to following:

```
php -S localhost:8081 www/router.php
```

The web server now serves as the REST API server. You can visit URL  to see if the server runs properly or not (If everything is good, the URL should return string "OK" back).

2. Create the configuration file "behat.yml" (optional).
--------------------------------------------------------

[](#2-create-the-configuration-file-behatyml-optional)

For the sample test provided, you can create the file by copying directly from file "behat.yml.dist" without any modifications required.

Note that you don't have to do this if you prefer to use file "behat.yml.dist" directly.

3. Run the test command.
------------------------

[](#3-run-the-test-command)

Now, run following command to test sample features:

```
./vendor/bin/behat
# OR
./vendor/bin/behat -p default # explicitly to use profile "default"
```

If everything is good, you should see the output as in following screenshot:

[![output when running Behat sample tests](https://camo.githubusercontent.com/ffefc760c46052c839a0eec9dbc3a15260668b8945a6f8f05c9f2ed1271e4357/68747470733a2f2f7261772e6769746875622e636f6d2f64656d696e792f62656861742d726573742d74657374696e672f6d61737465722f73637265656e73686f742e706e67)](https://camo.githubusercontent.com/ffefc760c46052c839a0eec9dbc3a15260668b8945a6f8f05c9f2ed1271e4357/68747470733a2f2f7261772e6769746875622e636f6d2f64656d696e792f62656861742d726573742d74657374696e672f6d61737465722f73637265656e73686f742e706e67)

TODOs
=====

[](#todos)

- Support different environments (development, QA, staging, production, etc).

License
=======

[](#license)

MIT license.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 99.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~210 days

Recently: every ~268 days

Total

8

Last Release

2708d ago

Major Versions

1.0.3 → 3.0.02016-01-10

1.x-dev → 3.0.12017-03-16

PHP version history (2 changes)1.0.0PHP &gt;=5.3.3

3.0.0PHP &gt;=5.4.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/865547?v=4)[Demin Yin](/maintainers/deminy)[@deminy](https://github.com/deminy)

---

Top Contributors

[![deminy](https://avatars.githubusercontent.com/u/865547?v=4)](https://github.com/deminy "deminy (122 commits)")[![sashaaro](https://avatars.githubusercontent.com/u/5504250?v=4)](https://github.com/sashaaro "sashaaro (1 commits)")

---

Tags

phprestBehat

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/deminy-behat-rest-testing/health.svg)

```
[![Health](https://phpackages.com/badges/deminy-behat-rest-testing/health.svg)](https://phpackages.com/packages/deminy-behat-rest-testing)
```

###  Alternatives

[abantecart/ups-php

UPS PHP SDK based on OAuth

1815.3k](/packages/abantecart-ups-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
