{"id":16423578,"url":"https://github.com/rougin/describe","last_synced_at":"2025-03-23T07:32:28.926Z","repository":{"id":23990049,"uuid":"27373425","full_name":"rougin/describe","owner":"rougin","description":"Obtain information of a database table.","archived":false,"fork":false,"pushed_at":"2024-10-19T17:41:14.000Z","size":174,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-18T18:46:53.273Z","etag":null,"topics":["database-access","describe","php-library"],"latest_commit_sha":null,"homepage":"https://roug.in/describe/","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/rougin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-12-01T10:03:07.000Z","updated_at":"2024-10-19T17:40:34.000Z","dependencies_parsed_at":"2024-10-28T15:28:44.609Z","dependency_job_id":"4991b1ae-0b85-4588-92c9-959f528e001a","html_url":"https://github.com/rougin/describe","commit_stats":{"total_commits":126,"total_committers":1,"mean_commits":126.0,"dds":0.0,"last_synced_commit":"b087cf72f4de693ae8838b05d1163f34c1e91579"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rougin%2Fdescribe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rougin%2Fdescribe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rougin%2Fdescribe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rougin%2Fdescribe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rougin","download_url":"https://codeload.github.com/rougin/describe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245072236,"owners_count":20556352,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-access","describe","php-library"],"created_at":"2024-10-11T07:40:20.378Z","updated_at":"2025-03-23T07:32:28.679Z","avatar_url":"https://github.com/rougin.png","language":"PHP","readme":"# Describe\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]][link-license]\n[![Build Status][ico-build]][link-build]\n[![Coverage Status][ico-coverage]][link-coverage]\n[![Total Downloads][ico-downloads]][link-downloads]\n\nDescribe is a PHP package that returns information about a table structure from a database.\n\n## Installation\n\nInstall `Describe` via [Composer](https://getcomposer.org/):\n\n``` bash\n$ composer require rougin/describe\n```\n\n## Basic Usage\n\nPrior in getting information of a table structure, a vendor-specific driver must be implemented:\n\n``` php\n// index.php\n\nuse Rougin\\Describe\\Driver\\MysqlDriver;\n\n$dsn = 'mysql:host=localhost;dbname=test';\n\n$pdo = new PDO($dsn, 'root', '');\n\n$driver = new MysqlDriver($pdo, 'test');\n```\n\nBelow are the available drivers for specified vendors:\n\n| **Driver**                               | **Description**                              | **Vendor**                                                                    |\n|------------------------------------------|----------------------------------------------|-------------------------------------------------------------------------------|\n| `Rougin\\Describe\\Driver\\MysqlDriver`     | Uses the `DESCRIBE` query.                   | [MySQL](https://www.mysql.com/)                                               |\n| `Rougin\\Describe\\Driver\\SqlServerDriver` | Uses the `INFORMATION_SCHEMA.COLUMNS` query. | [SQL Server](https://www.microsoft.com/en-us/sql-server/sql-server-downloads) |\n| `Rougin\\Describe\\Driver\\SqliteDriver`    | Uses the `PRAGMA table_info()` query.        | [SQLite](https://www.sqlite.org/)                                             |\n\nAlternatively, the `DatabaseDriver` can also be used to use a vendor-specific driver based on keyword:\n\n``` php\nuse Rougin\\Describe\\Driver\\DatabaseDriver;\n\n$creds = array('password' =\u003e '');\n\n$creds['hostname'] = 'localhost';\n$creds['database'] = 'test';\n$creds['username'] = 'root';\n\n$driver = new DatabaseDriver('mysql', $creds);\n```\n\n\u003e [!NOTE]\n\u003e `DatabaseDriver` is currently available to drivers `MysqlDriver` and `SqliteDriver` only.\n\nAfter specifying the driver, use the `columns` method to return a list of columns:\n\n``` php\n// index.php\n\n/** @var \\Rougin\\Describe\\Column[] */\n$columns = $driver-\u003ecolumns('users');\n```\n\n### Adding a new database driver\n\nTo add a new driver for a specified vendor, kindly implement it to a `DriverInterface`:\n\n``` php\nnamespace Rougin\\Describe\\Driver;\n\ninterface DriverInterface\n{\n    /**\n     * Returns a list of columns from a table.\n     *\n     * @param  string $table\n     * @return \\Rougin\\Describe\\Column[]\n     */\n    public function columns($table);\n\n    /**\n     * Returns a list of tables.\n     *\n     * @return \\Rougin\\Describe\\Table[]\n     */\n    public function tables();\n}\n```\n\n### Using `Table`\n\nThe `Table` class is similar with the `DriverInterface` with the difference that it can return the primary key from the list of columns:\n\n``` php\nuse Rougin\\Describe\\Table;\n\n$table = new Table('users', $driver);\n\n/** @var \\Rougin\\Describe\\Column[] */\n$columns = $driver-\u003ecolumns();\n\n/** @var \\Rougin\\Describe\\Column */\n$primary = $driver-\u003eprimary();\n```\n\nFor more information regarding the `Column` object, kindly check its [code documentation](https://github.com/rougin/describe/blob/master/src/Column.php).\n\n## Projects using Describe\n\nThe following projects below uses `Describe` as a valuable tool for getting a structure of a database table:\n\n* [Combustor](https://roug.in/combustor/)\n\nCombustor is a utility package for [Codeigniter 3](https://codeigniter.com/userguide3/) that generates controllers, models, and views based on the provided database tables. It uses the [Describe](https://roug.in/describe/) package for getting columns from a database table and as the basis for code generation.\n\n* [Refinery](https://roug.in/refinery/)\n\nRefinery is a console-based package of [Migrations Class](https://www.codeigniter.com/userguide3/libraries/migration.html) for the [Codeigniter 3](https://codeigniter.com/userguide3). It uses the [Describe](https://roug.in/describe/) package for retrieving the database tables for creating database migrations.\n\n## Changelog\n\nPlease see [CHANGELOG][link-changelog] for more information what has changed recently.\n\n## Testing\n\nThe unit tests for this package were written on [PHPUnit](https://phpunit.de/index.html):\n\n``` bash\n$ composer test\n```\n\n## Credits\n\n- [All contributors][link-contributors]\n\n## License\n\nThe MIT License (MIT). Please see [LICENSE][link-license] for more information.\n\n[ico-build]: https://img.shields.io/github/actions/workflow/status/rougin/describe/build.yml?style=flat-square\n[ico-coverage]: https://img.shields.io/codecov/c/github/rougin/describe?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/rougin/describe.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-version]: https://img.shields.io/packagist/v/rougin/describe.svg?style=flat-square\n\n[link-build]: https://github.com/rougin/describe/actions\n[link-changelog]: https://github.com/rougin/describe/blob/master/CHANGELOG.md\n[link-contributors]: https://github.com/rougin/describe/contributors\n[link-coverage]: https://app.codecov.io/gh/rougin/describe\n[link-downloads]: https://packagist.org/packages/rougin/describe\n[link-license]: https://github.com/rougin/describe/blob/master/LICENSE.md\n[link-packagist]: https://packagist.org/packages/rougin/describe","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frougin%2Fdescribe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frougin%2Fdescribe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frougin%2Fdescribe/lists"}