- How do I install robmorgan/phinx in a Laravel project?
- Install it with Composer using composer require robmorgan/phinx, then create a standalone phinx.php config file that reads your Laravel environment variables. Phinx runs from vendor/bin/phinx and does not register with Laravel's service container or migration repository, so you must manage its configuration separately.
- Does Phinx support Laravel 10, 11, and 12?
- Phinx requires PHP 8.1 or newer, which aligns with Laravel 10, 11, and 12 requirements. It is framework-agnostic and does not declare Laravel version constraints, but its Symfony Console 6, 7, and 8 compatibility makes it wrappable from Artisan. Validate the exact Phinx patch release against your Laravel and PHP versions before upgrading.
- What is the difference between Phinx and Laravel's built-in migrations?
- Laravel's migrator is a first-class subsystem with Artisan commands, a migrations table, and framework events. Phinx is a standalone engine with its own schema builder and phinxlog tracker, so using both creates two migration histories. Phinx is useful when one migration tool must cover Laravel and non-Laravel PHP services.
- Can I run Phinx migrations through an Artisan command?
- Yes, you can wrap Phinx in a custom Artisan command because Phinx uses Symfony Console underneath. The wrapper is typically a few dozen lines that invoke Phinx's migrate, rollback, or seed commands against your phinx.php config. It does not make Phinx part of Laravel's migrator or event system.
- Does Phinx support unique constraints on PostgreSQL tables?
- Phinx has a known limitation on PostgreSQL: it cannot set a unique constraint on a table, tracked as issue #1026 and still listed under Limitations. For PostgreSQL-heavy applications this can be a hard blocker, so verify your planned schema before adopting Phinx. MySQL, SQLite, and SQL Server have different adapter behavior and should be tested separately.
- Is it safe to run Phinx migrations in production on Laravel?
- Phinx is PDO-based and works alongside Laravel's connection layer, but MySQL implicitly commits DDL, so a failed migration can leave a partially applied schema with no phinxlog record. Pin an exact patch version because Phinx is 0.x and patch releases have removed protected adapter methods. Also assign DBA review for destructive or irreversible migrations before deploying.
- How do I test Phinx migrations in a Laravel application?
- Use a separate testing environment in phinx.php, typically pointing at an in-memory SQLite database or a disposable test schema. Phinx supports multi-environment config and SQLite :memory: for fast migration tests. Run migrate, rollback, and seed as part of CI, and keep Phinx tests separate from Laravel's Artisan migration tests.
- What are the risks of using Phinx and Laravel migrations together?
- You get two sources of truth with separate ordering mechanisms, a migrations table and a phinxlog table. Without explicit schema ownership, the two histories will drift. The safer patterns are greenfield services owned by Phinx or a per-database boundary enforced by separate CI jobs, rather than full consolidation.
- Is robmorgan/phinx actively maintained and production-ready?
- Phinx is at 0.x with no semver guarantee, and the repository has moved to cakephp/phinx while Packagist still uses the robmorgan/phinx vendor name. That donation is expected, but confirm your build pulls the canonical artifact. Pin exact versions and review changelogs on every patch upgrade.
- Which databases does Phinx support for Laravel applications?
- Phinx natively supports MySQL, PostgreSQL, SQLite, and Microsoft SQL Server through PDO adapters. That makes it a fit for polyglot estates that want one migration tool across Laravel, CakePHP, Symfony, and plain PHP services. It is less compelling for a single Laravel app already using native migrations.