{"id":36982179,"url":"https://github.com/jmsfwk/fluent-phinx","last_synced_at":"2026-01-13T22:52:06.448Z","repository":{"id":57000390,"uuid":"315443940","full_name":"jmsfwk/fluent-phinx","owner":"jmsfwk","description":"Laravel-style migrations for Phinx","archived":false,"fork":false,"pushed_at":"2021-03-04T12:18:08.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-18T21:52:42.744Z","etag":null,"topics":["database-migrations","laravel","phinx"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jmsfwk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-23T21:22:13.000Z","updated_at":"2021-03-04T12:18:03.000Z","dependencies_parsed_at":"2022-08-21T11:40:42.536Z","dependency_job_id":null,"html_url":"https://github.com/jmsfwk/fluent-phinx","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/jmsfwk/fluent-phinx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmsfwk%2Ffluent-phinx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmsfwk%2Ffluent-phinx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmsfwk%2Ffluent-phinx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmsfwk%2Ffluent-phinx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmsfwk","download_url":"https://codeload.github.com/jmsfwk/fluent-phinx/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmsfwk%2Ffluent-phinx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28402192,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database-migrations","laravel","phinx"],"created_at":"2026-01-13T22:52:06.379Z","updated_at":"2026-01-13T22:52:06.441Z","avatar_url":"https://github.com/jmsfwk.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fluent Phinx\n\nLaravel-style migrations for [Phinx][phinx].\n\n- [Introduction](#introduction)\n- [Migration Structure](#migration-structure)\n- [Tables](#tables)\n    - [Creating Tables](#creating-tables)\n    - [Updating Tables](#updating-tables)\n    - [Table Options](#table-options)\n- [Indexes](#indexes)\n    - [Creating Indexes](#creating-indexes)\n\n\u003ca name=\"introduction\"\u003e\u003c/a\u003e\n## Introduction\n\nPhinx provides a way to declare schemas in migrations, but it's somewhat difficult\nto use because of the array of options that vary by column type.\n\n*Fluent Phinx* provides a fluent Laravel-style schema builder to simplify writing\nand reading migrations.\n\n\u003ca name=\"migration-structure\"\u003e\u003c/a\u003e\n## Migration Structure\n\n*Fluent Phinx* relies on regular Phinx [migration files][creating-a-new-migration],\nwith either a `change` method or `up`/`down` method pair.\n\nThe `Fluent` trait can be used to add fluent functionality to the migration file.\n\n```php\n\u003c?php\n\nuse jmsfwk\\FluentPhinx\\Fluent;\nuse jmsfwk\\FluentPhinx\\Schema\\Blueprint;\nuse Phinx\\Migration\\AbstractMigration;\n\nclass CreateUsersTable extends AbstractMigration\n{\n    use Fluent;\n\n    public function change()\n    {\n        $this-\u003ecreate('users', function (Blueprint $table) {\n            $table-\u003eincrements('id');\n            $table-\u003estring('name');\n            \n            $table-\u003eid = false; // Turn off automatic id column\n            $table-\u003eprimary_key = 'id'; // Set the 'id' column as the primary key\n        });\n    }\n}\n```\n\n\u003ca name=\"tables\"\u003e\u003c/a\u003e\n## Tables\n\n\u003ca name=\"creating-tables\"\u003e\u003c/a\u003e\n### Creating Tables\n\nTo create a new database table, use the `create` method on from the `Fluent` trait. The create method accepts two\narguments: the first is the name of the table, while the second is a closure which receives a `Blueprint` object\nthat may be used to define the new table:\n\n```php\n$this-\u003ecreate('users', function (Blueprint $table) {\n    $table-\u003eincrements('id');\n});\n```\n\nWhen creating the table, you may use any of the schema builder's column methods to define the table's columns.\n\n\u003ca name=\"updating-tables\"\u003e\u003c/a\u003e\n### Updating Tables\n\nTo update a table the `update` method from the `Fluent` trait can be used. Like the `create` method this will accept\ntwo arguments: the name of the table, and a closure that receives a `Blueprint` object to define the changes.\n\n```php\n$this-\u003eupdate('users', function (Blueprint $table) {\n    $table-\u003einteger('votes');\n});\n```\n\n\u003ca name=\"table-options\"\u003e\u003c/a\u003e\n### Table Options\n\nYou may use the following properties on the schema builder to define the table's options:\n\nCommand  |  Description\n-------  |  -----------\n`$table-\u003eengine = 'InnoDB';`  |  Specify the table storage engine (MySQL).\n`$table-\u003ecollation = 'utf8mb4_unicode_ci';`  |  Specify a default collation for the table (MySQL).\n`$table-\u003ecomment = 'Explain something';`  |  Specify a comment for the table.\n`$table-\u003eid = 'id'`  |  The name of the automatically created id field (set to `false` to disable).\n`$table-\u003eprimary_key = 'id'`  |  The column to use as the primary key (can be set to an array of columns).\n`$table-\u003esigned = false`  |  Whether the primary key is signed (defaults to `true`).\n\n\u003ca name=\"indexes\"\u003e\u003c/a\u003e\n## Indexes\n\n\u003ca name=\"creating-indexes\"\u003e\u003c/a\u003e\n### Creating Indexes\n\nIndexes can be added in two places, from the column definition and from the `Blueprint` object.\n\nFrom the column you can pass the index name to the index method.\n\n```php\n$table-\u003estring('email')-\u003eunique();\n```\n\nTo create an index after defining the column, you should call the `unique` method on the schema builder \nblueprint. This method accepts the name of the column that should receive a unique index:\n\n```php\n$table-\u003eunique('email');\n```\n\nYou may pass an array of columns to an index method to create a compound (or composite) index:\n\n```php\n$table-\u003eindex(['account_id', 'created_at']);\n```\n\nWhen creating an index you may pass a second argument to the method to specify the index name:\n\n```php\n$table-\u003eunique('email', 'unique_email');\n```\n\n#### Available Index Types\n\nCommand | Description\n------- | -----------\n`$table-\u003eprimary('id');` | Adds a primary key.\n`$table-\u003eprimary(['id', 'parent_id']);` | Adds composite keys.\n`$table-\u003eunique('email');` | Adds a unique index.\n`$table-\u003eindex('state');` | Adds an index.\n\n[phinx]: https://book.cakephp.org/phinx/0/en/index.html\n[creating-a-new-migration]: https://book.cakephp.org/phinx/0/en/migrations.html#creating-a-new-migration\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmsfwk%2Ffluent-phinx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmsfwk%2Ffluent-phinx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmsfwk%2Ffluent-phinx/lists"}