A pure PHP MySQL 5.6 simulation engine for in-memory database testing without a real MySQL server.
PHP MySQL Engine is a library written in pure PHP that simulates MySQL 5.6 for testing database-driven applications. It allows developers to run SQL queries against an in-memory database without needing a real MySQL server, solving the performance and maintenance issues of traditional database testing approaches. It extends PDO to provide a drop-in replacement for MySQL connections in test environments.
PHP developers with extensive test suites that require database interactions, particularly those at organizations like Vimeo who need to test data access layers without the overhead of real databases.
Developers choose PHP MySQL Engine because it eliminates the fragility of query mocks and the performance costs of real databases in tests, offering a fast, in-memory alternative that supports a wide range of MySQL syntax and integrates seamlessly via PDO.
A MySQL engine written in pure PHP
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Eliminates database truncation between tests, significantly speeding up test execution for small datasets, as highlighted in the motivation section comparing it to real databases.
Supports a wide range of MySQL 5.6 syntax including JOINs, subqueries, and functions like COUNT() and CONCAT_WS(), making it suitable for testing complex queries without mocking.
Extends the PDO class, allowing seamless integration with existing codebases that use PDO for database interactions, as shown in the usage example with FakePdo instantiation.
The validating parser throws exceptions on invalid SQL queries, helping catch syntax errors early in development before they reach production, as mentioned in the SQL Syntax Supported section.
Does not support MySQL stored procedures, triggers, or views, limiting its use for applications that rely on these database features, as explicitly stated in the unsupported features section.
When not emulating prepares, result types may differ from actual MySQL, leading to potential discrepancies in strict type checks, as noted in the known issues about column type inference.
The project lacks an issue tracker and is maintained with minimal community engagement, meaning users must rely on their own resources for bug fixes, as warned in the caveat emptor section.
Simulates only MySQL 5.6, so newer MySQL features are not available, which might be a drawback for modern applications using updated syntax or capabilities.