This project aims to provide a bridge between Mink and legacy apps. In general terms, legacy apps are not written with the best practices in mind or they are too old to support them.
Legacy apps are hard to maintain mainly because of the lack of tests or because of very slow and painful tests. This situation produces fear to change as the side effects are unknown. In addition to this, legacy apps use to suffer from the following situations:
- No usage of composer autoload.
- Rely on PHP superglobals (like
$_GET
,$_POST
,$_SERVER
, etc). - Having many frontend controllers.
- Usage of
exit
/die
to abruptly finish the request.
Install with:
$ composer require --dev carlosv2/mink-legacy-driver
Set up your behat.yml
file as follows:
default:
extensions:
carlosV2\LegacyDriver\Extension: ~
Behat\MinkExtension:
sessions:
default:
legacy:
environment: <array>
controller: <string|array>
document_root: <string>
bootstrap: <string|array>
Where:
-
environment
: Key/value array containing the environment variables. For example:environment: variable: value env: prod
-
controller
: Location of the frontend controller. For example:controller: path/to/the/controller.php
Alternatively you can supply an array of frontend controllers. For example:
controller: - path: /uri/to/match file: path/to/the/uri/to/match.php - path: /uri/to/another file: another/path/to/match.php
The controllers key configures the
symfony/routing
component underneath. As a result, you can also add themethods
andrequirements
keys. For example:controller: - path: /item/{id} file: process_item.php methods: ["GET", "PUT"] requirements: id: \d+
-
document_root
: Location of the document root. For example:document_root: path/to/the/document/root/
-
bootstrap
: Location of the bootstrap file to execute before every request. For example:bootstrap: path/to/the/bootstrap/file.php
Alternatively you can supply multiple files to be executed before every request. For example:
bootstrap: - path/to/the/bootstrap/file.php - another/path/to/bootstrap.php