PHPackages                             rougin/describe - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. rougin/describe

ActiveLibrary

rougin/describe
===============

Obtain information of a database table.

v1.8.1(1y ago)28.2k32MITPHPPHP &gt;=5.3.0CI failing

Since Apr 1Pushed 8mo ago2 watchersCompare

[ Source](https://github.com/rougin/describe)[ Packagist](https://packagist.org/packages/rougin/describe)[ Docs](https://roug.in/describe/)[ RSS](/packages/rougin-describe/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (19)Used By (2)

Describe
========

[](#describe)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a66faaa729e3a3ad27fd6882129e9fb0e7a43d08b14e37d739581cfd410a82f6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726f7567696e2f64657363726962652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rougin/describe)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/rougin/describe/blob/master/LICENSE.md)[![Build Status](https://camo.githubusercontent.com/80ff1b4a81f2ffcbd2f39a826bd179756766e4870207594eb609d0b55b4fb8cc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f726f7567696e2f64657363726962652f6275696c642e796d6c3f7374796c653d666c61742d737175617265)](https://github.com/rougin/describe/actions)[![Coverage Status](https://camo.githubusercontent.com/f829cdaa9af17b6fee298ec99fb8932d9fd375983bd9f0acbef5fc2eac24fc76/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f726f7567696e2f64657363726962653f7374796c653d666c61742d737175617265)](https://app.codecov.io/gh/rougin/describe)[![Total Downloads](https://camo.githubusercontent.com/ade656cf596fedac273f7b66ba9e2132194b6a49afc5dfdaf4d7a3e2f510f216/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726f7567696e2f64657363726962652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rougin/describe)

Describe is a PHP package that returns information about a table structure from a database.

Installation
------------

[](#installation)

Install `Describe` via [Composer](https://getcomposer.org/):

```
$ composer require rougin/describe
```

Basic usage
-----------

[](#basic-usage)

`Describe` requires a vendor-specific driver to get a database table's structure:

```
// index.php

use Rougin\Describe\Driver\MysqlDriver;

$dsn = 'mysql:host=localhost;dbname=test';

$pdo = new PDO($dsn, 'root', '');

$driver = new MysqlDriver($pdo, 'test');
```

Below are the available drivers for specified vendors:

**Driver****Description****Vendor**`Rougin\Describe\Driver\MysqlDriver`Uses the `DESCRIBE` query.[MySQL](https://www.mysql.com/)`Rougin\Describe\Driver\SqlServerDriver`Uses the `INFORMATION_SCHEMA.COLUMNS` query.[SQL Server](https://www.microsoft.com/en-us/sql-server/sql-server-downloads)`Rougin\Describe\Driver\SqliteDriver`Uses the `PRAGMA table_info()` query.[SQLite](https://www.sqlite.org/)Alternatively, the `DatabaseDriver` can also be used to use a vendor-specific driver based on keyword:

```
use Rougin\Describe\Driver\DatabaseDriver;

$creds = array('password' => '');

$creds['hostname'] = 'localhost';
$creds['database'] = 'test';
$creds['username'] = 'root';

$driver = new DatabaseDriver('mysql', $creds);
```

After specifying the driver, use the `columns` method to return a list of columns:

```
// index.php

/** @var \Rougin\Describe\Column[] */
$columns = $driver->columns('users');
```

Using `Table`
-------------

[](#using-table)

The `Table` class is similar with the `DriverInterface` with the difference that it can return the primary key from the list of columns:

```
use Rougin\Describe\Table;

$table = new Table('users', $driver);

/** @var \Rougin\Describe\Column[] */
$columns = $driver->columns();

/** @var \Rougin\Describe\Column */
$primary = $driver->primary();
```

For more information regarding the `Column` object, kindly check its [code documentation](https://github.com/rougin/describe/blob/master/src/Column.php).

Adding a new database driver
----------------------------

[](#adding-a-new-database-driver)

Use the `DriverInterface` for implementing a vendor-specific driver:

```
namespace Rougin\Describe\Driver;

interface DriverInterface
{
    /**
     * Returns a list of columns from a table.
     *
     * @param string $table
     *
     * @return \Rougin\Describe\Column[]
     */
    public function columns($table);

    /**
     * Returns a list of tables.
     *
     * @return \Rougin\Describe\Table[]
     */
    public function tables();
}
```

Use-cases
---------

[](#use-cases)

The following projects below uses `Describe` as a valuable tool:

### Combustor

[](#combustor)

[Combustor](https://roug.in/combustor/) 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 `Describe` for getting columns from a database table and as the basis for code generation.

### Refinery

[](#refinery)

[Refinery](https://roug.in/refinery/) 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 `Describe` for retrieving the database tables for creating database migrations.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](https://github.com/rougin/describe/blob/master/CHANGELOG.md) for more recent changes.

Development
-----------

[](#development)

Includes configuration for code quality, coding style, and unit tests.

Note

The sub-sections below are for those who need to access the package's source code for development, such as creating fixes or new features.

### Code quality

[](#code-quality)

Analyze code quality using [phpstan](https://phpstan.org/):

```
$ phpstan
```

### Coding style

[](#coding-style)

Enforce coding style using [php-cs-fixer](https://cs.symfony.com/):

```
$ php-cs-fixer fix --config=phpstyle.php
```

### Unit tests

[](#unit-tests)

Execute unit tests using [phpunit](https://phpunit.de/index.html):

```
$ composer test
```

Credits
-------

[](#credits)

Big thanks to [all contributors](https://github.com/rougin/describe/contributors) in this package!

License
-------

[](#license)

This package uses the [MIT Licenses (MIT)](https://github.com/rougin/describe/blob/master/LICENSE.md).

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance49

Moderate activity, may be stable

Popularity25

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~205 days

Recently: every ~740 days

Total

18

Last Release

576d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c7721589a958a1fbcef1b527c794d820d75b82988f14b2ed86a1c6904d76a59e?d=identicon)[rougin](/maintainers/rougin)

---

Top Contributors

[![rougin](https://avatars.githubusercontent.com/u/6078637?v=4)](https://github.com/rougin "rougin (156 commits)")

---

Tags

database-accessdescribephp-libraryphpdescribedatabase-table

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rougin-describe/health.svg)

```
[![Health](https://phpackages.com/badges/rougin-describe/health.svg)](https://phpackages.com/packages/rougin-describe)
```

###  Alternatives

[pestphp/pest-plugin-stressless

Stressless plugin for Pest

67792.6k16](/packages/pestphp-pest-plugin-stressless)[ozzie/pest-plugin-nest

Nest Pest PHP tests for better organization and readability

2028.3k](/packages/ozzie-pest-plugin-nest)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
