Download the PHP package drevops/behat-phpserver without Composer

On this page you can find all versions of the php package drevops/behat-phpserver. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package behat-phpserver

Behat PHP server logo

PHP and API server for Behat tests

[![GitHub Issues](https://img.shields.io/github/issues/drevops/behat-phpserver.svg)](https://github.com/drevops/behat-phpserver/issues) [![GitHub Pull Requests](https://img.shields.io/github/issues-pr/drevops/behat-phpserver.svg)](https://github.com/drevops/behat-phpserver/pulls) [![Test PHP](https://github.com/drevops/behat-phpserver/actions/workflows/test-php.yml/badge.svg)](https://github.com/drevops/behat-phpserver/actions/workflows/test-php.yml) [![codecov](https://codecov.io/gh/drevops/behat-phpserver/branch/main/graph/badge.svg?token=KZCCZXN5C4)](https://codecov.io/gh/drevops/behat-phpserver) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/drevops/behat-phpserver) [![Total Downloads](https://poser.pugx.org/drevops/behat-phpserver/downloads)](https://packagist.org/packages/drevops/behat-phpserver) ![LICENSE](https://img.shields.io/github/license/drevops/behat-phpserver) ![Renovate](https://img.shields.io/badge/renovate-enabled-green?logo=renovatebot) [![Vortex Ecosystem](https://img.shields.io/badge/%F0%9F%8C%80-Vortex%20Ecosystem-2C5A68?style=for-the-badge&labelColor=65ACBC)](https://github.com/drevops/vortex)

✨ Features

📦 Installation

Requires PHP 8.2 or newer.

composer require --dev drevops/behat-phpserver

🚀 Usage

PhpServerContext

Serves static assets from a pre-defined document root.

This context adds no step definitions. It starts the server before a tagged scenario and stops it afterwards, so tag the scenarios that need it:

Tagging the Feature: line instead starts the server for every scenario in that feature.

Reach the running server through getServerUrl() - see Accessing the server URL from your own context.

ApiServerContext

Serves pre-set API responses. It extends PhpServerContext, so it accepts the same options plus paths.

Context options

Option Default Description
webroot See below Document root the server serves from. Must exist, or the constructor throws.
host 127.0.0.1 Server host.
port 8888 Server port.
protocol http Server protocol, used to build the server URL.
debug false Print verbose output about server start, stop and connection attempts.
connection_timeout 2 Seconds to keep retrying a connection before the server is declared failed.
retry_delay 100000 Microseconds to wait between connection retries.
paths <webroot>/../tests/behat/fixtures ApiServerContext only. One path or a list of paths searched, in order, for file responses.

ApiServerContext defaults webroot to the bundled apiserver directory. PhpServerContext has no usable default, so always set it.

Both contexts default to port 8888. When both are registered, give each one its own port, as shown above.

📖 Step definitions

Server lifecycle

Queueing responses

Responses are replayed in the order they were queued, one per request.

Assertions and debugging

Both assertion steps also accept the alternative phrasings the API server should have received 3 requests and the API server should have 0 responses queued, and both accept a singular noun for a count of one.

See the test feature for worked examples of every step.

File responses

API will respond with file reads a file from the configured paths, searching each path in the order given until it finds a match. The content type is derived from the file extension:

Extension Content-Type
.json application/json
.xml application/xml
.html, .htm text/html
.txt text/plain
anything else application/octet-stream

Accessing the server URL from your own context

To point an API client at the running server, read the URL in a beforeScenario hook:

🔌 API server HTTP endpoints

The step definitions cover the common cases. The mock server also exposes the endpoints directly, which is useful when driving it from code rather than from Gherkin.

Method Endpoint Result
GET /admin/status 200 OK. Reports the counts in the headers below.
GET /admin/requests 200 OK with the recorded requests as JSON.
DELETE /admin/requests 200 OK. Clears the recorded requests.
GET /admin/responses 200 OK with the queued responses as JSON.
DELETE /admin/responses 200 OK. Clears the queued responses.
PUT /admin/responses 201 Created. Appends the posted responses to the queue.

These endpoints and the replayed responses carry an X-Received-Requests and an X-Queued-Responses header with the current counts. Error responses do not.

Any other request is recorded and answered with the next queued response. When the queue is empty, the server answers 500 with No responses in queue.

PUT /admin/responses takes an array of response objects:

body must be base64-encoded - the server decodes it before replaying the response. The step definitions do this encoding for you, so it only matters when calling the endpoint directly. code must be between 100 and 599; reason must be a non-empty string; header names and values must be scalars.

🤝 Contributing

See CONTRIBUTING.md for local setup, linting, testing and maintenance.


This repository was created using the Scaffold project template


All versions of behat-phpserver with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
behat/behat Version ^3.32.0 || ^4.0@alpha
guzzlehttp/guzzle Version ^7.15.3 || ^8
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package drevops/behat-phpserver contains the following files

Loading the files please wait ...