PHPackages                             vincentchalamon/api-extension - 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. vincentchalamon/api-extension

AbandonedArchivedLibrary[API Development](/categories/api)

vincentchalamon/api-extension
=============================

Behat extension for API Platform

2.0.x-dev(6y ago)611.4k5[8 issues](https://github.com/vincentchalamon/api-extension/issues)[2 PRs](https://github.com/vincentchalamon/api-extension/pulls)MITPHPPHP &gt;=7.2

Since Jul 13Pushed 6y ago1 watchersCompare

[ Source](https://github.com/vincentchalamon/api-extension)[ Packagist](https://packagist.org/packages/vincentchalamon/api-extension)[ RSS](/packages/vincentchalamon-api-extension/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (4)Dependencies (28)Versions (8)Used By (0)

ApiExtension
============

[](#apiextension)

[![Build Status](https://camo.githubusercontent.com/ba83bdbbadb4581220f78020780bdc97ed372bd76cbea0d2f40189bd3c58a07d/68747470733a2f2f7472617669732d63692e6f72672f76696e63656e746368616c616d6f6e2f6170692d657874656e73696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/vincentchalamon/api-extension)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/0abbd0a6c09015e0e5a186dbad20bfa2a96bf6dbf6ed380b2b62cae468ebf65e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f76696e63656e746368616c616d6f6e2f6170692d657874656e73696f6e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/vincentchalamon/api-extension/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/cd450da1e6d197f4e94ffdaec88bc37e1808c054b2ab94e306801a2498e9fb38/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f76696e63656e746368616c616d6f6e2f6170692d657874656e73696f6e2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/vincentchalamon/api-extension/?branch=master)

This Behat extension requires following extensions, check their documentations for installation &amp; usage:

- [Symfony2Extension](https://github.com/Behat/Symfony2Extension)
- [Behatch](https://github.com/Behatch/contexts)
- [MinkExtension](https://github.com/Behat/MinkExtension)

**This extension is just a shortcut to write some steps, it doesn't replace your custom steps.** For instance, if you want to test that updating a user updates its password, you still need to add a customer step like `And the user password has been successfully updated`.

Install
-------

[](#install)

```
composer require --dev vincentchalamon/api-extension
```

Declare required extensions in your Behat configuration:

```
# behat.yml.dist
default:
    # ...
    suites:
        default:
            contexts:
                - Behat\MinkExtension\Context\MinkContext
                - Behatch\Context\RestContext
                - Behatch\Context\JsonContext
                - ApiExtension\Context\ApiContext
                - ApiExtension\Context\FixturesContext
    extensions:
        Behat\Symfony2Extension:
            kernel:
                bootstrap: features/bootstrap/bootstrap.php
                class: App\Kernel
        Behat\MinkExtension:
            base_url: 'http://www.example.com/'
            sessions:
                default:
                    symfony2: ~
        Behatch\Extension: ~
        # ...
        ApiExtension: ~
```

### Using custom guessers for populator

[](#using-custom-guessers-for-populator)

```
# behat.yml.dist
default:
    # ...
    extensions:
        # ...
        ApiExtension:
            guessers:
              - App\Populator\Guesser\AcustomGuesser
              - App\Populator\Guesser\AnotherCustomGuesser
```

Usage with Symfony FrameworkBundle &lt; 4.1
-------------------------------------------

[](#usage-with-symfony-frameworkbundle--41)

Running with Symfony FrameworkBundle &lt; 4.1, you need to override some private services:

```
# config/services_test.yaml

# Hack for Behat: allow to inject some private services
services:
    test.property_info:
        parent: property_info
        public: true
    test.api_platform.metadata.resource.metadata_factory.annotation:
        parent: api_platform.metadata.resource.metadata_factory.annotation
        public: true
    test.api_platform.iri_converter:
        parent: api_platform.iri_converter
        public: true
    test.annotation_reader:
        parent: annotation_reader
        public: true
    test.router:
        parent: router
        public: true
```

```
# behat.yml.dist
default:
    # ...
    extensions:
        # ...
        ApiExtension:
            services:
                metadataFactory: '@test.api_platform.metadata.resource.metadata_factory.annotation'
                iriConverter: '@test.api_platform.iri_converter'
                registry: '@doctrine'
                propertyInfo: '@test.property_info'
                annotationReader: '@test.annotation_reader'
                router: '@test.router'
```

Usage
-----

[](#usage)

FixturesContext provides the following steps:

- `the following `
- `there is  `
- `there is a `
- `there is an `
- `there are  `
- `there are `
- `there are   with:`

ApiContext provides the following steps:

- `I get a list of `
- `I get a list of  filtered by `
- `I get a list of  ordered by `
- `I create a `
- `I create an `
- `I create a  using group `
- `I create a  using groups `
- `I create an  using group `
- `I create an  using groups `
- `I create a  with:`
- `I create an  with:`
- `I create a  using group  with:`
- `I create a  using groups  with:`
- `I create an  using group  with:`
- `I create an  using groups  with:`
- `I get a `
- `I get an `
- `I get the  `
- `I delete a `
- `I delete an `
- `I delete the  `
- `I update a `
- `I update an `
- `I update the  `
- `I update a  with:`
- `I update an  with:`
- `I update the   with:`
- `the request is invalid`
- `the  is not found`
- `the method is not allowed`
- `I see a `
- `I see an `
- `I see a list of `
- `I see a list of  `
- `I don't see any `
- `print  list JSON schema`
- `print  item JSON schema`
- `print last JSON request`

Example:

```
Feature: Using API-Platform, I can get, create, update & delete beers.

  Scenario: I can get a list of beers
    Given there are beers
    When I get a list of beers
    Then I see a list of beers

  Scenario: I can get a list of beers filtered by name
    Given there are beers
    When I get a list of beers filtered by name=Chouffe
    Then I don't see any beer

  Scenario: I can create a beer
    When I create a beer
    Then I see a beer

  Scenario: I can create a beer
    When I create a beer with:
      | name    |
      | Chouffe |
    Then I see a beer

  Scenario: I can update a beer
    Given there is a beer
    When I update a beer
    Then I see a beer

  Scenario: I can update a beer and fill its new name
    Given there is a beer
    When I update a beer with:
      | name    |
      | Chouffe |
    Then I see a beer

  Scenario: I can update a beer by its name
    Given the following beer:
      | name    |
      | Chouffe |
    When I update the beer Chouffe
    Then I see a beer

  Scenario: I can update a beer by its name and fill its new name
    Given the following beer:
      | name    |
      | Chouffe |
    When I update the beer Chouffe with:
      | name |
      | Kwak |
    Then I see a beer

  Scenario: I can get a beer
    Given there is a beer
    When I get a beer
    Then I see a beer

  Scenario: I can get a beer by its name
    Given the following beer:
      | name    |
      | Chouffe |
    When I get the beer Chouffe
    Then I see a beer

  Scenario: I cannot get a non-existing beer
    When I get a beer
    Then the beer is not found

  Scenario: I can delete a beer
    Given there is a beer
    When I delete a beer
    Then the beer has been successfully deleted

  Scenario: I can delete a beer by its name
    Given the following beer:
      | name    |
      | Chouffe |
    When I delete the beer Chouffe
    Then the beer has been successfully deleted
```

Add faker provider
------------------

[](#add-faker-provider)

To use a [custom faker provider](https://github.com/fzaninotto/Faker#faker-internals-understanding-providers) from [fzaninotto/Faker](https://github.com/fzaninotto/Faker), update your Behat configuration as following:

```
# behat.yml.dist
default:
    # ...
    extensions:
        # ...
        ApiExtension:
            # ...
            providers:
                - App\Faker\Provider\MiscellaneousProvider
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92% 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 ~154 days

Total

5

Last Release

2244d ago

Major Versions

1.0.0-beta.4 → 2.0.x-dev2020-03-23

PHP version history (2 changes)1.0.0-betaPHP &gt;=7.0

2.0.x-devPHP &gt;=7.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/407859?v=4)[Vincent](/maintainers/vincentchalamon)[@vincentchalamon](https://github.com/vincentchalamon)

---

Top Contributors

[![vincentchalamon](https://avatars.githubusercontent.com/u/407859?v=4)](https://github.com/vincentchalamon "vincentchalamon (69 commits)")[![jordanaubert](https://avatars.githubusercontent.com/u/16880485?v=4)](https://github.com/jordanaubert "jordanaubert (5 commits)")[![Mathieudewet](https://avatars.githubusercontent.com/u/10513229?v=4)](https://github.com/Mathieudewet "Mathieudewet (1 commits)")

---

Tags

api-platformbehatextension

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/vincentchalamon-api-extension/health.svg)

```
[![Health](https://phpackages.com/badges/vincentchalamon-api-extension/health.svg)](https://phpackages.com/packages/vincentchalamon-api-extension)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M310](/packages/easycorp-easyadmin-bundle)

PHPackages © 2026

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