cakephp/phinx
53.5
Adequate · 19 September 2026
19.1k
lines of production code
PHP
primary language
1
measurement over time
What this system is
This system is Phinx, a PHP-based database migration and seeding tool that manages schema changes across multiple database platforms. It provides a command-line interface and a programmatic API to define, execute, and rollback database migrations using a structured, transactional execution engine. The system supports complex schema operations, including foreign key management and index handling, while offering configuration flexibility through JSON, YAML, and PHP formats.
How it got here
2012 — Initial project scaffolding and core library development
23 changes.
This period established the foundational structure of the Phinx database migration tool, introducing the core CLI interface, database adapter layer, and migration execution engine. It involved implementing essential features such as transactional migrations, multi-format configuration support, and type-safe schema definitions, while simultaneously setting up comprehensive unit test coverage and development workflows.
2014–2018 — Core architecture and seeding features
15 changes.
This period focused on refactoring the core migration engine by breaking down monolithic table change methods into granular action and plan classes to improve reliability and conflict resolution. It also introduced significant new capabilities, including database seeding with dependency management, a programmatic text wrapper, and a web-based runner for HTTP-driven migration execution.
2019–2022 — Migration plan solver and regression testing
10 changes.
This period focused on enhancing the database migration planning engine by introducing an ActionSplitter class to resolve conflicts in alter table instructions. Significant effort was dedicated to expanding test coverage, particularly through regression tests for complex foreign key and column manipulation scenarios, alongside improvements to configuration templates and console output utilities.
Features
Add Phinx CLI entry points for Unix and Windows
Users can now run the Phinx migration tool directly from the command line via the new \bin/phinx\ executable for Unix-like systems and \bin/phinx.bat\ for Windows. The Unix script bootstraps the application by requiring \app/phinx.php\ and running it, while the Windows batch file handles environment detection (checking for \PHP\_COMMAND\ or falling back to \php.exe\) and invokes the main script, ensuring consistent CLI access across operating systems.
bin · high confidence
Added Phinx database migration configuration templates
The data directory now includes distribution templates for the Phinx database migration tool (phinx.json.dist, phinx.php.dist, and phinx.yml.dist). These files provide default configurations for MySQL connections across production, development, and testing environments, allowing users to easily set up database migrations with predefined paths for migrations and seeds.
data · high confidence
Added Phinx web runner for HTTP-based migration management
The application now includes a new web entry point (app/web.php) that allows Phinx migration commands to be executed via HTTP requests. This script acts as a simple router, mapping URL paths to Phinx console commands such as status, migrate, and rollback. It supports query string parameters for specifying the environment (e), target version (t), and enabling debug mode, allowing users to manage database migrations through a web interface or API-like interaction.
app · high confidence
Initial project scaffolding and configuration
This change establishes the foundational structure for the Phinx database migration tool. It introduces essential configuration files including \.editorconfig\ and \.gitattributes\ to standardize coding styles and Git export behavior, alongside \.gitignore\ to exclude build artifacts and IDE metadata. Development and testing workflows are enabled through \phpunit.xml.dist\, \phpstan.neon\, and \phpcs.xml\ (enforcing CakePHP3 standards), while \box.json\ configures the Phar build process. The project also adds a Docker development environment (\Dockerfile\, \docker-compose.yml\) and updates documentation with a new \README.md\ and \CONTRIBUTING.md\ guide.
(repo-wide) · high confidence
Initial release of Phinx console application
This change introduces the Phinx console application entry point, registering core migration commands (init, create, migrate, rollback, status, breakpoint, test, seed-create, seed-run, and list-aliases) and configuring the default --configuration option. It also implements version detection via Composer's InstalledVersions or build-time git tags, and ensures version information is displayed on run unless suppressed by --no-info or the help command.
src/Phinx/Console · high confidence
Initial release of Phinx database migration library
This entry marks the initial commit of the Phinx library, introducing the core \Phinx\\Db\\Table\ class and its supporting action classes (such as \AddColumn\, \AddForeignKey\, \ChangeColumn\, etc.) and plan classes (\Intent\, \Plan\). This foundational code provides the API for defining database schema changes, including table creation, column management, index handling, and foreign key constraints, serving as the base for all subsequent migration features.
src/Phinx/Db · high confidence
Introduce Composer autoloader helper
A new \src/composer\_autoloader.php\ file has been added to provide a standardized way to load Composer's \autoload.php\. This helper attempts to locate the autoloader in both dependency and stand-alone package configurations, returning true if successful or false if the autoloader cannot be found, thereby simplifying dependency initialization for users.
src · high confidence
Introduce TextWrapper for programmatic Phinx command execution
Adds the new \Phinx\\Wrapper\\TextWrapper\ class, which provides a programmatic interface to run Phinx migration commands (\status\, \migrate\, \seed:run\, \rollback\) and retrieve their output as plain text. This wrapper allows applications to execute database migrations and seeds via code rather than the CLI, supporting configuration options like environment, configuration file, parser, and specific seed names or rollback targets.
src/Phinx/Wrapper · high confidence
Introduction of database seeding capability
This change introduces the database seeding feature, adding the \AbstractSeed\ class, \SeedInterface\, and a seed template to allow users to populate databases with initial data. The implementation supports dependency injection via a PSR-11 container, allows seeds to declare execution dependencies for ordered runs, and provides methods to execute SQL, insert data, and control execution flow.
src/Phinx/Seed · high confidence
Migration classes now accept console input and output via constructor
The migration base classes and interfaces in \src/Phinx/Migration\ have been updated to accept \InputInterface\ and \OutputInterface\ instances directly in their constructors. This allows migration and seed classes to access console input and output streams, enabling them to display information or prompt users during execution without relying on global state or indirect injection.
src/Phinx/Migration · high confidence
New ActionSplitter class for resolving plan conflicts
A new ActionSplitter class has been added to the plan solver to handle specific types of conflicts during database migration planning. This component partitions AlterTable instructions into non-conflicting sequences by identifying dual action types (such as AddColumn and DropColumn) and using a configurable filter to determine which actions should be grouped together, thereby improving the efficiency and correctness of the generated migration plans.
src/Phinx/Db/Plan/Solver · high confidence
New AlterInstructions utility for batched table alterations
A new \AlterInstructions\ class has been added to the \Phinx\\Db\\Util\ namespace to manage the components of an ALTER TABLE command. This utility allows users to define pre-steps, alter parts, and post-steps as SQL strings or callables, and supports MySQL-specific ALGORITHM and LOCK clauses. It includes a \merge\ method to combine multiple instruction sets, ensuring that conflicting algorithm or lock specifications are detected and rejected, which facilitates safer batched database migrations.
src/Phinx/Db/Util · high confidence
New utility classes for SQL expressions and literals
Added \Expression\ and \Literal\ classes in the \Phinx\\Util\ namespace to wrap raw SQL strings, allowing them to be passed safely without being interpreted as column or table names. These new utility classes complement the existing \Util\ class, which provides helpers for migration file naming, timestamp generation, and class name mapping.
src/Phinx/Util · high confidence
Architecture
Database adapter layer refactored with CakePHP Query Builder and new wrapper architecture
The database adapter subsystem has been restructured to integrate the CakePHP database layer, introducing a new \AdapterFactory\ for centralized adapter and wrapper registration, and a \DirectActionInterface\ to allow adapters to execute schema changes directly. The core \PdoAdapter\ now utilizes the CakePHP \Query\ builder for data operations and supports \Cake\\I18n\\Date\ and \DateTime\ objects in inserts. Additionally, the new \AdapterWrapper\ base class and \TablePrefixAdapter\ enable output and configuration interception, while the \AbstractAdapter\ now handles data domain configuration and schema table naming.
src/Phinx/Db/Adapter · high confidence
Behavioural changes
Configuration system refactored with JSON support and feature flags
The configuration system in src/Phinx/Config has been restructured to support multiple configuration file formats, including the newly added JSON support via the new fromJson() factory method alongside existing YAML and PHP parsers. The Config class now implements a new ConfigInterface and integrates with a new FeatureFlags class, allowing users to toggle breaking changes (such as unsigned primary keys, column null defaults, and datetime vs. timestamp columns) via a feature\_flags section in their config. Additionally, the system now supports namespace-aware migration and seed paths through the new NamespaceAwareInterface and NamespaceAwareTrait, enabling automatic namespace resolution based on directory structure.
src/Phinx/Config · high confidence
Introduction of dedicated Table, Column, Index, and ForeignKey model classes
The \src/Phinx/Db/Table\ directory now contains dedicated model classes (\Column\, \ForeignKey\, \Index\, \Table\) that replace the previous string-based or ad-hoc definitions for database schema elements. This change introduces structured objects for defining columns (with support for types, limits, defaults, and database-specific options like collation), foreign keys (with explicit ON DELETE/UPDATE actions and deferrable modes), and indexes (supporting named indexes, sort orders, and included columns). Users will now interact with these specific classes when building migrations, allowing for more robust and type-safe schema definitions compared to the previous approach.
src/Phinx/Db/Table · high confidence
Introduction of transactional migration and seeding execution
The Environment class now wraps migration and seed execution in database transactions when the underlying adapter supports them. For migrations, this ensures that changes are committed only if the entire operation succeeds, and it enables reversible 'change' migrations by recording commands in a proxy adapter during rollback. Seeds are similarly executed within a transactional boundary, providing atomicity for data seeding operations.
src/Phinx/Migration/Manager · high confidence
Phinx console commands rewritten for Symfony 5 and modern PHP
The console command layer has been completely rewritten to target Symfony 5 and PHP 8.1+. All commands (migrate, rollback, create, seed, etc.) now use the Symfony \\#\[AsCommand\]\ attribute for registration and define their names via \protected static $defaultName\ to avoid deprecation warnings. The codebase enforces strict typing (\declare(strict\_types=1)\) and native type declarations. New capabilities include a \breakpoint\ command for managing rollback targets, a \list:aliases\ command for template aliases, and a \test\ command for validating configuration and database connections. The \init\ command now supports JSON, YAML, and PHP config formats, and the \status\ command can output JSON. Exit codes are standardized via class constants.
src/Phinx/Console/Command · high confidence
Refactored database actions into dedicated domain classes
The \src/Phinx/Db/Action\ directory has been restructured to replace the previous monolithic \Table::change()\ method with specific, dedicated action classes for each database operation. This change introduces an abstract \Action\ base class and concrete implementations for \AddColumn\, \ChangeColumn\, \RemoveColumn\, \RenameColumn\, \AddForeignKey\, \DropForeignKey\, \AddIndex\, \DropIndex\, \RenameTable\, \DropTable\, \ChangePrimaryKey\, and \ChangeComment\. Each class encapsulates the data required for its specific migration step (such as column definitions, foreign key constraints, or index configurations) and provides static \build\ factory methods to simplify instantiation. This separation allows the migration engine to handle individual schema changes more granularly and improves type safety and maintainability.
src/Phinx/Db/Action · high confidence
Refactored database migration planning into a structured, conflict-resolving execution engine
The migration planning logic in \src/Phinx/Db/Plan\ has been restructured to improve reliability and maintainability. New classes (\AlterTable\, \Intent\, \NewTable\) now explicitly model the intent and structure of table changes, separating the collection of actions from their execution. The \Plan\ class orchestrates these actions by grouping them into specific categories (creates, updates, moves, indexes, constraints, column removals) and resolving conflicts—such as dropping foreign keys before columns or handling simultaneous add/drop operations. This ensures that migrations, particularly rollbacks and complex schema changes involving foreign keys and indexes, are executed in a deterministic and correct order.
src/Phinx/Db/Plan · high confidence
Test coverage
Added PHPUnit bootstrap for configurable test database connections; Added PostgreSQL migration snapshot test fixture; Added regression test for dropping tables with foreign keys; Added regression tests for dropping columns with foreign keys and indexes; Added regression tests for foreign key and column migration edge cases; Added seed fixtures for testing dependency ordering and execution control; Added test fixtures for Phinx configuration parsing; Added test fixtures for Phinx migration and seed validation; Added test fixtures for Phinx migration parsing; Added test fixtures for migration execution filtering; Added test fixtures for migration path handling; Added test fixtures for migration validation edge cases; Added test fixtures for reversible migration scenarios; Added test helper for Phinx config command; Added test helper for raw console output buffering; Added test templates for custom seeder template configuration; Added tests for PhinxApplication CLI behavior; Added tests for TextWrapper environment handling; Added tests for the Environment class; Added unit tests for Phinx Db Table operations; Added unit tests for Phinx Util classes; Added unit tests for Phinx console commands; Added unit tests for Table, Column, ForeignKey, and Index components; Added unit tests for database adapter components; Added unit tests for migration and seed core classes; Added unit tests for template class generated migrations; Expanded unit test coverage for Phinx Config class.
Dependencies
Update dependencies and minimum PHP version
The project now requires PHP 8.1 or higher and has updated its core dependencies to support modern versions of the Symfony ecosystem (Config, Console, and YAML versions 4.0 through 8.0) and CakePHP Database (version 5.0.2). Development tools have also been upgraded, including PHPUnit to version 10.5 and the addition of specific coding standards and i18n packages for testing and linting.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Baseline
- First survey — no prior run to compare against. CAI 54.
Lenses
- Code Health 86
- Architecture 68
- Maturity 38
- Readiness 68
- Security 64
Changes since last survey
- 300 commits — 215 feature/other, 85 fixes
By area
- src/Phinx — 99 commits
- (repo) — 61 commits
- (root) — 46 commits
- .github/workflows — 39 commits
- docs/en — 31 commits
- tests/Phinx — 18 commits
- docs/config — 2 commits
- docs/fr — 2 commits
- .github/dependabot.yml — 1 commit
- docs/gh-pages — 1 commit
Notable commits
- fix: Add test for mysql zero scale column def fix (#2378)
- fix: Fix --dry-run option when values to insert are booleans (#2358)
- fix: Fix 2193 Postgres GENERATED ALWAYS (#2195)
- fix: Fix CS
- fix: Fix CS
- fix: Fix CS (#2349)
- fix: Fix Decimal Column Definition Issue When Scale is 0 (#2377)
- fix: Fix FK constraint violations on implicit table drops for sqlite (#2131)
- fix: Fix PHP version used in packaging
- fix: Fix README badges
- fix: Fix SQL injection in hasDatabase() by quoting database name in adapters (#2418)
- fix: Fix SQLiteAdapter::getColumns with Literal column (#2331)
- fix: Fix SqlServerAdapter returning empty string instead of null for column default (#2090)
- fix: Fix blank line above declare statement, see PSR-12 (#2175)
- fix: Fix breakpoint column to disallow nulls (#2162)
- fix: Fix build status README badge (#2356)
- fix: Fix cache key for phar workflow (#2382)
- fix: Fix commands cross-reference
- fix: Fix custom column types not working anymore.
- fix: Fix defaultName deprecation warning on symfony/console 6.1 (#2107)
- …and 280 more
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
cakephp/phinx was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 19 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 69e8718d75660b49475fa627d019dbed1c4646db — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-13a154b7f5d1.