# minkphp/Mink: PHP Browser Automation Across Sessions

> minkphp/Mink is a PHP abstraction for browser automation that lets test code work with named sessions and page elements through driver-specific implementations. It is useful for teams maintaining PHP web tests, but drivers and session lifecycle still require integration decisions.

**minkphp/Mink** — PHP web browser emulator abstraction

- Repository: https://github.com/minkphp/Mink
- Website: https://mink.behat.org/
- Stars: 1,606 · Forks: 285
- Language: PHP
- License: MIT
- Published: 2026-10-16 · Updated: 2026-10-16 · Language: en
- Canonical page: https://hysenlabs.com/projects/minkphp-mink

## Why Minkphp/Mink Exists in PHP Test Suites

minkphp/Mink addresses a specific boundary in PHP web testing: test code needs to control browsers and inspect pages, but browser libraries expose different implementations and object models. Mink provides a PHP-level abstraction above those implementations. The repository describes itself as a “PHP web browser emulator abstraction,” and its usage example separates test-facing operations from the Goutte driver implementation.

The intended users are PHP developers working with browser-driven tests, especially code that needs more than one browser session. Mink supports selecting sessions by name and setting a default session. That design matters when a test needs to keep separate browsing states, such as two sessions navigating different parts of the same site or isolating interactions from a custom session.

Mink does not, according to the README, include a browser binary, a server, or a complete test framework. The example imports `GoutteDriver`, `Session`, and `Mink` from the package, while `MyCustomDriver` appears as a placeholder for a project-specific driver. The abstraction is therefore most useful when the application under test is already reachable and the team is willing to choose or implement a driver.

## Minkphp/Mink’s Session and Driver Data Flow

The documented flow begins by constructing a `Mink` object with named sessions. Each session wraps a driver, and the driver is responsible for the browser-facing operations that the Mink API abstracts. In the README example, two named sessions use `GoutteDriver`, while a third named session uses `MyCustomDriver($startUrl)`.

After registration, `setDefaultSessionName('goutte2')` determines which session `getSession()` returns without an argument. A test can then call `visit($startUrl)` on the default session and obtain a page through `getPage()`. Page operations such as `findLink('Downloads')` and `click()` are expressed through the page object rather than through the concrete driver shown in the example.

Named access is explicit: `getSession('custom')` returns the custom session, and `getSession('goutte1')` returns the first Goutte session. The README describes this arrangement as making it possible to mix sessions. This is a useful separation of concerns for tests that need distinct cookies, navigation histories, or driver configurations. However, the README does not document automatic browser cleanup, process isolation, parallel execution, retry behavior, or a failure policy. Those lifecycle details must come from the driver and the surrounding test code.

## Installing Minkphp/Mink Through Composer

The README provides a repository-level Composer setup sequence rather than a complete application installation tutorial. The commands below are copied from the README. The first command downloads Composer’s installer and the second installs the dependencies declared by the project. The README places these commands under “Install Dependencies,” so a reader working in a checkout of this repository can use them as the documented starting point.

```bash
$> curl -sS https://getcomposer.org/installer | php
$> php composer.phar install
```

The command output and success conditions are not specified in the README. The repository contains `composer.json`, so the installation step depends on Composer reading that package definition. The README does not state a PHP version, a Composer version, or a specific Mink version to install.

For an application that consumes Mink, the README does not provide the application-specific `composer.json` entry. The practical distinction is important. These commands install the dependencies of a Mink checkout; they do not by themselves show how to register Mink in a separate PHP project. The README points to https://mink.behat.org for the main documentation, but it does not reproduce package installation details there.

## A First Named-Session Navigation Example

The README’s first usage example shows the smallest complete flow available in the documentation. It initializes `Mink`, registers three sessions, chooses one as the default, visits a URL, and finds a link by its visible name.

```php
<?php

use Behat\Mink\Mink,
    Behat\Mink\Session,
    Behat\Mink\Driver\GoutteDriver,
    Behat\Mink\Driver\Goutte\Client as GoutteClient;

$startUrl = 'http://example.com';

$mink = new Mink(array(
    'goutte1' => new Session(new GoutteDriver(new GoutteClient())),
    'goutte2' => new Session(new GoutteDriver(new GoutteClient())),
    'custom'  => new Session(new MyCustomDriver($startUrl))
));

$mink->setDefaultSessionName('goutte2');
$mink->getSession()->visit($startUrl);
$mink->getSession()->getPage()->findLink('Downloads')->click();
```

The example then retrieves page content from the default session and accesses the `custom` session by name. The longer README example also clicks `Chat` independently in `goutte1` and `goutte2`, demonstrating that session state can be kept separate through the named API. The exact selector behavior, link matching rules, and result of clicking a link are not documented beyond the method calls shown. The target page must contain links matching the names used by the test.

## Driver Boundaries and Configuration Costs

Mink’s abstraction does not remove the work of selecting a working browser driver. The README explicitly shows `GoutteDriver`, a custom driver, and a `GoutteClient`, which means the package’s main value is consistent integration rather than universal browser coverage. A team adopting Mink must still identify which driver supports its required navigation, page lookup, and click behavior.

The example also shows that a driver can receive application-specific state. `MyCustomDriver($startUrl)` is instantiated with the starting URL, while Goutte is constructed with `new GoutteClient()`. That is evidence that driver configuration belongs outside the shared Mink registry. It is not evidence that every driver accepts the same constructor arguments or exposes the same capabilities.

The repository includes `phpstan.dist.neon`, `phpunit.xml.dist`, and a `tests/` directory, which indicates that the project has source-level quality and test configuration. The README does not include their contents, so their exact PHP requirements, supported drivers, and test commands cannot be confirmed here. The top-level `CHANGES.md` is also present, but the README does not summarize it. Upgrade planning should therefore include reading the release changes and checking the selected driver’s compatibility instead of assuming that a Mink release alone updates browser behavior.

## Why Minkphp/Mink Is Not a Standalone Browser Runner

The clearest limitation is that Mink is an abstraction, not a complete web automation environment. The repository description calls it an emulator abstraction, and the usage example depends on a concrete driver. The README does not show how to start a browser, install browser binaries, capture artifacts, manage proxies, or run tests from the command line.

That limitation can become a failure mode when a team needs a single package to provide the full execution path. If the chosen driver lacks a required operation, the shared API does not create that missing capability automatically. If the driver requires external configuration, initializing `Session` is only part of the setup. The `MyCustomDriver` placeholder also indicates that custom integrations are possible, but the README does not provide a complete custom driver implementation.

A direct approach would be to use one browser automation library’s native API throughout the test suite. That can be simpler when there is only one driver and only one session. Mink becomes more relevant when PHP tests need to share application-facing operations while selecting among multiple drivers or named sessions. The trade-off is an extra abstraction and a dependency on the driver contract.

## Minkphp/Mink Releases, Licensing, and Upgrade Work

The repository is not archived, and the last push was on 2026-09-01. The release history lists `v1.13.0` on 2025-11-22, `v1.12.0` on 2024-10-30, and `v1.11.0` on 2023-12-09. These are Mink package releases. The README does not state which underlying browser or HTTP client versions each release supports.

The project is identified as MIT licensed. The repository includes a `LICENSE` file, and Composer displays a license badge in the README. The license permits use under its stated terms, but this article does not interpret those terms or provide legal advice. Teams should still review the repository license and the licenses of installed drivers and client libraries separately.

Upgrade cost depends on the integration surface. Changes to the `Mink`, `Session`, or driver APIs could require code changes in custom drivers, while driver or client dependency changes could affect browser behavior. Because the README does not document a compatibility matrix, migration commands, or a rollback procedure, those points cannot be treated as resolved by the release list alone.

## Conclusion

Adopt minkphp/Mink when PHP test code needs a shared browser automation API and multiple named sessions. Do not treat it as a complete browser stack without checking the selected driver, its dependency requirements, and the behavior of your target site. The first verification should be whether your Composer setup and chosen driver can provide every page interaction your tests need.

## FAQ

### What is minkphp/Mink used for?

minkphp/Mink is a PHP abstraction for browser automation. It provides `Mink`, `Session`, and page operations while allowing tests to select named sessions backed by drivers such as `GoutteDriver`.

### How do I install minkphp/Mink?

The README gives a Composer setup sequence: download the Composer installer, then run `php composer.phar install` in the repository. It does not provide a separate application-level `composer.json` command for consuming Mink.

### Does minkphp/Mink include a browser driver?

The usage example uses `GoutteDriver` and `GoutteClient`, and it also shows a `MyCustomDriver` placeholder. The repository presents Mink as the abstraction, while the driver is an integration point.

## Sources

- [License: MIT](https://github.com/minkphp/Mink/blob/master/LICENSE)
- [minkphp/Mink on GitHub](https://github.com/minkphp/Mink)
- [Project website](https://mink.behat.org/)
- [README](https://github.com/minkphp/Mink/blob/master/README.md)
- [Releases](https://github.com/minkphp/Mink/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/minkphp-mink
