PHPackages                             taluu/behapi - 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. [API Development](/categories/api)
4. /
5. taluu/behapi

ActiveLibrary[API Development](/categories/api)

taluu/behapi
============

Test your remote api locally through Behat

v0.14.1(3y ago)3212.7k↓87.5%4[5 issues](https://github.com/Taluu/Behapi/issues)MITPHPPHP ^7.3 || ^8.0

Since Mar 25Pushed 3y ago3 watchersCompare

[ Source](https://github.com/Taluu/Behapi)[ Packagist](https://packagist.org/packages/taluu/behapi)[ RSS](/packages/taluu-behapi/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (15)Versions (24)Used By (0)

Behapi
======

[](#behapi)

Behat extension to help write describe features related to HTTP APIs.

PHP 7.3, Behat 3.7 and a discoverable php-http client are required to make this extension work.

Installing this extension requires you to require `taluu/behapi` and an implementation of a http client (providing `psr/http-client-implementation ^1.0`, `psr/http-factory-implementation ^1.0` and `psr/http-message-implementation ^1.0`).

You can find some examples on the `examples/` directory.

Howto
-----

[](#howto)

Add this in your behat.yml (it's for the `default` configuration but you can use it for any configurations actually) :

```
default:
  suites:
    main:
      paths: ['%paths.base%/features']
      services: '@Behapi\Container'
      autowire: true

      contexts:
        #- List
        #- your
        #- contexts
        #- here

        # examples :
        - Behapi\Http\RequestContext: ~
        - Behapi\Http\ResponseContext: ~

  extensions:
    Behapi\Behapi:
      base_url: 'http://localhost'
```

The `base_url` is the only requirement in the config for this extension to work.

There are other configurations keys, such as which formatter to use in a debug environment, which headers you want to output in request or response while debugging ; Use the `--config-reference` flag when invoking behat to have more information on the available configuration.

After having installed the extension, you can then use the provided contexts such as the `Behapi\Http\RequestContext` for the http api operations. In order to use them, you need to use behapi's container (`@Behapi\Container`), or a container capable of using behapi's container.

Some services are provided to be injected in contexts, which are the following:

- `@Http\Client\Common\PluginClientBuilder`, which will build a `Http\Client\Common\PluginClient` when needed
- `@Behapi\HttpHistory\History`, which is a sort of a container with the last requests done and last responses received
- `@Http\Message\MessageFactory`
- `@Http\Message\StreamFactory`

*Note:* You don't really need to bother with the services names, as they are compatible with behat's auto-wiring feature.

In order to enable the Json assertions, you need to use the `Behapi\Context\Json` context. Note that if you use the json context, you should have used the client provided by the client builder used in the `Behapi\Http\RequestContext` context.

If you need to play with the request being built, or the response created when the request is sent, you need to inject the `@Behapi\HttpHistory\History`. It is automatically reseted between scenarios (and scenarios outlines)

A documentation will be made (soon hopefully) with more details.

Contributing
------------

[](#contributing)

Contributing (issues, pull-requests) are of course always welcome ! Be sure to respect the standards (such as psr-2, ... etc), follow proper git etiquette (atomic commits, ...), proper conduct too and it should be fine !

Thanks
------

[](#thanks)

This extension was made while I was working at [@Wisembly](https://github.com/Wisembly), and heavily used for writing our features and integration tests. Special thanks goes to [@lunika](https://github.com/lunika), [@rgazelot](https://github.com/rgazelot)and [@krichprollsch](https://github.com/krichprollsch), who helped conceived this extension, and also pushed me to open-source it.

Badges
------

[](#badges)

[![Type Coverage](https://camo.githubusercontent.com/8f2820d76e0487e5133789eaa3f2c58524845a9cbe31d80145c496be441cb096/68747470733a2f2f73686570686572642e6465762f6769746875622f54616c75752f4265686170692f636f7665726167652e737667)](https://shepherd.dev/github/Taluu/Behapi)

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 96% 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 ~90 days

Recently: every ~350 days

Total

23

Last Release

1396d ago

PHP version history (3 changes)v0.1PHP ^7.1

v0.13.0PHP ^7.3

v0.14.0PHP ^7.3 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/a0a8e7ce68ae5cfe2ad58504dffc6d4e5ca05291dcde032048a70c3f8e9e7e3a?d=identicon)[Talus](/maintainers/Talus)

---

Top Contributors

[![Taluu](https://avatars.githubusercontent.com/u/239685?v=4)](https://github.com/Taluu "Taluu (356 commits)")[![krichprollsch](https://avatars.githubusercontent.com/u/562696?v=4)](https://github.com/krichprollsch "krichprollsch (7 commits)")[![lunika](https://avatars.githubusercontent.com/u/767834?v=4)](https://github.com/lunika "lunika (4 commits)")[![rgazelot](https://avatars.githubusercontent.com/u/1488251?v=4)](https://github.com/rgazelot "rgazelot (2 commits)")[![guillaumepotier](https://avatars.githubusercontent.com/u/496234?v=4)](https://github.com/guillaumepotier "guillaumepotier (1 commits)")[![Titoine](https://avatars.githubusercontent.com/u/3514286?v=4)](https://github.com/Titoine "Titoine (1 commits)")

---

Tags

apibddbehatbehat-contextsbehat-extensionphpphp71restapiBehatextensioncontexts

###  Code Quality

TestsBehat

### Embed Badge

![Health badge](/badges/taluu-behapi/health.svg)

```
[![Health](https://phpackages.com/badges/taluu-behapi/health.svg)](https://phpackages.com/packages/taluu-behapi)
```

###  Alternatives

[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

35789.4k2](/packages/telnyx-telnyx-php)[openai-php/client

OpenAI PHP is a supercharged PHP API client that allows you to interact with the Open AI API

5.8k28.0M318](/packages/openai-php-client)[getbrevo/brevo-php

Official Brevo provided RESTFul API V3 php library

1003.9M50](/packages/getbrevo-brevo-php)[n1ebieski/ksef-php-client

PHP API client that allows you to interact with the API Krajowego Systemu e-Faktur

9067.8k](/packages/n1ebieski-ksef-php-client)[trycourier/courier

Courier PHP SDK

15660.9k](/packages/trycourier-courier)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28150.5k](/packages/phpro-http-tools)

PHPackages © 2026

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