Mink

A PHP browser emulator abstraction that unifies web acceptance testing across drivers.

Library
Composer
vv1.13.0
1,611stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
48/100Fair
Development Activity0
Maintenance20
Community84
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
79/100Good
Architecture86
Code Quality84
Innovation72
Learning Curve72

Mink is a PHP library that provides a single, consistent API for controlling a web browser in acceptance tests, regardless of the underlying driver. It abstracts away the differences between fast headless browser emulators (like Goutte/BrowserKit) and real, JavaScript-capable browsers driven through Selenium or WebDriver, so the same test code can run against either.

Through its Session, Page/Element, and WebAssert objects, Mink lets you visit pages, fill and submit forms, click links, select elements with CSS or XPath, and assert on the resulting page state. It integrates tightly with Behat for BDD-style web testing but works as a standalone library in any PHP test suite.

What You Get

  • A Session API to drive navigation, form interaction, and page inspection across any supported driver
  • Element selection via CSS or XPath through a consistent Element/NodeElement model
  • A WebAssert helper for expressive assertions on page content, status, and elements
  • A pluggable driver architecture spanning headless emulators and real Selenium/WebDriver browsers

Common Use Cases

  • Writing web acceptance tests that run the same against a headless emulator or a real browser
  • Driving JavaScript-heavy pages through Selenium while keeping test code driver-agnostic
  • Powering Behat scenarios that exercise a web application end to end

Under The Hood

Architecture — The core Mink.php registers named sessions, each wrapping a Session.php that pairs a Driver implementation with a SelectorsHandler. Interactions go through Element objects (DocumentElement, NodeElement) that translate CSS/XPath selectors via the Selector subsystem into driver calls, while WebAssert.php provides high-level assertions. Drivers implement a shared DriverInterface, so backends are interchangeable.

Tech Stack — Pure PHP, distributed via Composer. Concrete drivers (BrowserKit/Goutte, Selenium2/WebDriver, etc.) live in separate companion packages that plug into Mink’s driver interface.

Code Quality — The tests/ tree mirrors the source (Driver, Element, Exception, Selector) and includes a driver test-suite contract that companion driver packages run against to prove conformance — a strong pattern for keeping a multi-backend abstraction consistent.

API Design — The API reads naturally for test authors: $session->visit(), $page->fillField(), $page->pressButton(), $assert->pageTextContains(). Because every driver honors the same interface, tests written once remain portable across emulated and real browsers with no code changes.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search