{"id":14987447,"url":"https://github.com/codenomdev/codeigniter4-schemas","last_synced_at":"2026-01-27T08:02:34.566Z","repository":{"id":56955508,"uuid":"282417529","full_name":"codenomdev/codeigniter4-schemas","owner":"codenomdev","description":"Database schema management, for CodeIgniter 4","archived":false,"fork":false,"pushed_at":"2020-07-25T10:48:41.000Z","size":38,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-01T07:57:44.067Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codenomdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-25T10:02:02.000Z","updated_at":"2021-12-10T00:33:30.000Z","dependencies_parsed_at":"2022-08-21T08:50:32.412Z","dependency_job_id":null,"html_url":"https://github.com/codenomdev/codeigniter4-schemas","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/codenomdev/codeigniter4-schemas","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenomdev%2Fcodeigniter4-schemas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenomdev%2Fcodeigniter4-schemas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenomdev%2Fcodeigniter4-schemas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenomdev%2Fcodeigniter4-schemas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codenomdev","download_url":"https://codeload.github.com/codenomdev/codeigniter4-schemas/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenomdev%2Fcodeigniter4-schemas/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28809336,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T07:41:26.337Z","status":"ssl_error","status_checked_at":"2026-01-27T07:41:08.776Z","response_time":168,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":[],"created_at":"2024-09-24T14:14:37.747Z","updated_at":"2026-01-27T08:02:34.550Z","avatar_url":"https://github.com/codenomdev.png","language":"PHP","readme":"# codeigniter4-schemas\nDatabase schema management, for CodeIgniter 4\n\n## Quick Start\n\n1. Install with Composer: `\u003e composer require codenom/schemas`\n2. Generate a new schema: `\u003e php spark schemas`\n\n## Features\n\n* View your entire database mapped out in a cascading structure\n* Read or detect table relationships for easy object-relation mapping (see e.g. [Tatter\\Relations](https://github.com/tattersoftware/codeigniter4-relations))\n* Get helpful advice on optimizations to your database structure with schema analysis\u003csup\u003e1\u003c/sup\u003e\n* Backup, restore, or deploy an entire database structure between servers or environments\u003csup\u003e1\u003c/sup\u003e\n* Generate CodeIgniter 4 migration files from an existing database\u003csup\u003e1\u003c/sup\u003e\n* Transfer projects to CodeIgniter 4 by reading schema files from other supported formats\u003csup\u003e1\u003c/sup\u003e\n\n\u003csup\u003e1\u003c/sup\u003e Some features are still in development. See **Handlers \u003e Development** for\nplanned future expansion.\n\n## Installation\n\nInstall easily via Composer to take advantage of CodeIgniter 4's autoloading capabilities\nand always be up-to-date:\n* `\u003e composer require codenom/schemas`\n\nOr, install manually by downloading the source files and adding the directory to\n`app/Config/Autoload.php`.\n\n## Configuration (optional)\n\nThe library's default behavior can be altered by extending its config file. Copy\n**bin/Schemas.php** to **app/Config/** and follow the instructions\nin the comments. If no config file is found in **app/Config** the library will use its own.\n\n## Usage\n\n**Schemas** has four main functions, each with a variety of handlers available:\n* *Draft*: Generates a new schema from a variety of sources\n* *Archive*: Stores a copy of a schema for later use\n* *Read*: Loads a schema for live access\n* *Publish*: (not yet available) Modifies environments to match schema specs\n\nThe **Schemas** service is also available to simplify a workflow with convenient wrapper functions.\nAt its most basic (with automation enabled), the service will draft, archive, and return\na schema with one simple command:\n\n\t$schema = service('schemas')-\u003eget();\n\nYou may want to control when portions of the workflow take place to optimize performance.\nHere is an example of one common process, mapping the default database group and storing\nthe resulting schema to the cache:\n\n```\n// Map the database and store the schema in cache\n$schemas = service('schemas');\n$schemas-\u003edraft('database')-\u003earchive('cache');\n\n// Load the schema from cache, add Model data, and get the updated schema\n$schema = $schemas-\u003eread('cache')-\u003edraft('model')-\u003eget();\n```\n\nIf you need to deviate from default handler configurations you can inject the handlers yourself:\n```\n$db = db_connect('alternate_database');\n$databaseHandler = new \\Codenom\\Schemas\\Drafter\\Handlers\\DatabaseHandler(null, $db);\n$schema = $schemas-\u003edraft($databaseHandler)-\u003eget();\n```\n\n## Command\n\n**Schemas** comes with a `spark` command for convenient schema generation and display:\n\n\t`schemas [-draft handler1,handler2,...] [-archive handler1,... | -print]`\n\nUse the command to test and troubleshoot, or add it to your cron for periodic schema caching:\n\n\tphp spark schemas -draft database,model -archive cache\n\n## Automation\n\nBy default automation is turned on, but this can be configured via the `$automate` toggles\nin your config file. Automation will allow the service to fall back on a Reader, or even on\na Drafter should it fail to have a schema already loaded. While automation makes using the\nlibrary very easy, it can come at a performance cost if your application is not configured\ncorrectly, since it may draft a schema on every page load. Use automation to help but don't\nlet it become a crutch.\n\n## Structure\n\n**Schemas** uses foreign keys, indexes, and naming convention to detect relationships\nautomatically. Make sure your database is setup using the appropriate keys and\nforeign keys to assist with the detection. Naming conventions follow the format of\n`{table}_id` for foreign keys and `{table1}_{table2}` for pivot tables. For more examples\non relationship naming conventions consult the Rails Guide\n[Active Record Associations](https://guides.rubyonrails.org/association_basics.html#the-types-of-associations)\n(and please excuse the Ruby reference).\n\n### Intervention\n\nShould autodetection fail or should you need to deviate from conventions there are a few\ntools you can use to overwrite or augment the generated schema.\n\n* **Config/Schemas**: the Config file includes a variable for `$ignoredTables` that will let you skip tables entirely. By default this includes the framework's `migrations` table.\n* **app/Schemas/{file}.php**: The `DirectoryHandler` will load any schemas detected in your **Schemas** directory - this gives you a chance to specify anything you want. See [tests/_support/Schemas/Good/Products.php](tests/_support/Schemas/Good/Products.php) for an example.\n\n## Drafting\n\nCurrently supported handlers:\n\n* Database\n* Model\n* PHP\n* Directory (PHP import only)\n\n## Archiving/reading\n\n* Cache\n\n## Database Support\n\nAll CodeIgniter 4 database drivers work but due to some differences in index handling they\nmay not all report the same results. Example: see skipped tests for SQLite3.\n\n## Development\n\nThe eventual goal is to support mapping from and deploying to any source. Planned handler\nimplementations include:\n\n* `Publisher\\DatabaseHandler`: Recreate a live database from its schema\n* `MigrationsHandler`: Create a schema from migration files, or vice versa\n* `FileHandler`: A wrapper for importing and exporting from popular schema file formats\n* Lots more...\n\nAnd the file-specific handlers:\n* `PhpHandler-\u003earchive()`: Create a PHP file with a Schema object in `$schema`\n* `XmlHandler`: Support for Doctrine-style XML files\n* More to come...\n\nWant to help out? All code and issues are managed on GitHub at [Codenom\\Schemas](https://github.com/codenomdev/codeigniter4-schemas)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodenomdev%2Fcodeigniter4-schemas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodenomdev%2Fcodeigniter4-schemas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodenomdev%2Fcodeigniter4-schemas/lists"}