Description
Behat extension to help write describe features related to HTTP APIs.
PHP 7.1, Behat 3.4, and a discoverable php-http client are required to make
this extension work.
Behapi alternatives and similar libraries
Based on the "API" category.
Alternatively, view Behapi alternatives based on common mentions on social networks and blogs.
-
API Platform
πΈοΈ Create REST and GraphQL APIs, scaffold Jamstack webapps, stream changes in real-time. -
Restler
Simple and effective multi-format Web API Server to host your PHP API as Pragmatic REST and/or RESTful API -
wsdl2phpgenerator
DISCONTINUED. Simple utility and class library for generating php classes from a wsdl file. -
OverblogGraphQLBundle
This bundle provides tools to build a complete GraphQL API server in your Symfony App. -
Pinterest Bot for PHP
DISCONTINUED. This PHP library will help you to work with your Pinterest account without using any API account credentials. -
Slack for PHP
A simple PHP package for sending messages to Slack, with a focus on ease of use and elegant syntax. -
Drest
Quickly and easily expose Doctrine entities as REST resource endpoints with the use of simple configuration with annotations, yaml, json or a PHP array. -
chubbyphp-framework
A minimal, highly performant middleware PSR-15 microframework built with as little complexity as possible, aimed primarily at those developers who want to understand all the vendors they use. -
cidaas SDK for php
With this SDK, you can integrate cidaas smoothly and with minimal effort into your PHP application. It enables you to map the most important user flows for OAuth2 and OIDC compliant authentication. Secure β Fast β And unrivaled Swabian. -
yii2-fractal
A set of utils and actions for build API following JSON:Api specification, based on league/fractal -
icanhazstring/expressive-hashids-middleware
PSR-15/PSR-7 compliant middleware using ivanakimov/hashids.php
InfluxDB - Purpose built for real-time analytics at any scale.
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Behapi or a related project?
README
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
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:
@Behapi\Http\PluginClientBuilder
, which will build aHttp\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 (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
This extension was made while I was working at @Wisembly, and heavily used for writing our features and integration tests. Special thanks goes to @lunika, @rgazelot and @krichprollsch, who helped conceived this extension, and also pushed me to open-source it.