Mink is a PHP library that gives developers a single, driver-agnostic interface for driving and interrogating web pages through interchangeable browser-emulation sessions, aimed at PHP teams writing tests and scraping workflows.
What it is
Mink is an abstraction layer written in PHP and distributed as the Composer package behat/mink. It sits between your application code and the concrete mechanism that fetches and renders a page, presenting both through the same Session object. A Mink instance holds one or more named sessions, each constructed from a driver — for example new Session(new GoutteDriver(new GoutteClient()), 'goutte2') — and a default session can be designated with setDefaultSessionName() so that a bare getSession() call returns it.
The problem it solves is that PHP code which navigates a site, clicks links, and reads page content would otherwise have to be rewritten whenever the underlying fetcher changes. By routing everything through getSession()->getPage() methods such as findLink('Downloads')->click() and getContent(), the same script works against a Goutte-backed session, a custom driver such as MyCustomDriver($startUrl), or any other driver plugged into the abstraction. Because sessions are addressed by name, several can coexist in one process and be used interchangeably.
Key capabilities
- Holds multiple named sessions in a single
Mink instance, so getSession('goutte1') and getSession('goutte2') return distinct active contexts within one script.
- Sets a default session via
setDefaultSessionName('goutte2'), letting getSession() with no argument resolve to the configured default.
- Drives pages through a uniform page API:
getPage()->findLink('Downloads')->click() and getPage()->getContent() work the same regardless of driver.
- Wraps the Goutte fetcher through
GoutteDriver and GoutteClient, giving a non-browser HTTP-based session out of the box.
- Accepts user-supplied drivers directly, as illustrated by
MyCustomDriver($startUrl) in the usage example.
- Supports mixing sessions in sequence, visiting and clicking within
goutte1, goutte2, and custom sessions in the same run.
- Is installed as the Packagist package
behat/mink, with stable and unstable versions published and download counts tracked on Packagist.
Who uses it and how
- PHP teams that write browser-driven tests, since the project lives in the Behat orbit — documentation is hosted at
https://mink.behat.org/ and support is handled through the Behat Google Group.
- Developers who navigate a site programmatically: the README flow visits a start URL, follows a link by its text, and reads back the resulting page content.
- Projects that need more than one fetching context at once, running a Goutte-backed session alongside a custom session and switching between them by name within one script.
- Contributors maintaining driver integrations, with three named lead developers (
everzet, stof, aik099) and an active CI workflow at .github/workflows/tests.yml.
- Consumers tracking library stability through Packagist badges for the latest stable version, unstable version, total downloads, and license.
Getting started
Install the Composer installer and run php composer.phar install in the project to pull in the dependencies; the library itself is behat/mink on Packagist.
How it compares
Mink integrates with Goutte through GoutteDriver and GoutteClient while still permitting a driver of your own design, so it does not commit a codebase to one fetcher. No comparable abstraction tools are named in the available facts, so Mink stands alone in this registry as the project of its kind described here.
When to use it — and when not
You must supply a driver yourself or depend on one such as GoutteDriver, so a user needs a working PHP environment with Composer-managed dependencies and no self-hosted service to operate. It is not the right pick for those outside the PHP ecosystem, and readers should note the 79 open issues alongside the MIT licence when judging maturity before adopting it.