PHPackages                             dlid/cdbyuml - 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. [Database &amp; ORM](/categories/database)
4. /
5. dlid/cdbyuml

ActiveLibrary[Database &amp; ORM](/categories/database)

dlid/cdbyuml
============

PHP classes for generating database models using yuml.me

v1.0(11y ago)167MITPHPPHP &gt;=5.4

Since Oct 11Pushed 11y ago1 watchersCompare

[ Source](https://github.com/dlid/cdbyuml)[ Packagist](https://packagist.org/packages/dlid/cdbyuml)[ Docs](https://github.com/dlid/cdbyuml)[ RSS](/packages/dlid-cdbyuml/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

[![Build Status](https://camo.githubusercontent.com/7ab59d861c280f4bb1b5190a3aadc2f57abceca9c2cd4ef0a3dba20db1c8e20b/68747470733a2f2f7472617669732d63692e6f72672f646c69642f63646279756d6c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/dlid/cdbyuml)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/29aa0e68e3cf2bb217a8a5659f2839b5819841fa454e93e86e2506b06a34f3f2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f646c69642f63646279756d6c2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/dlid/cdbyuml/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/847cc4b327f6ca06fe54515a1153beecb9600a1b4f2facb55324f7e7e5893030/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f646c69642f63646279756d6c2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/dlid/cdbyuml/?branch=master)

[![Latest Stable Version](https://camo.githubusercontent.com/556670dbb8a3249a4ea9d36ea20102e6236681f517cb2f1d5df140e076698b47/68747470733a2f2f706f7365722e707567782e6f72672f646c69642f63646279756d6c2f762f737461626c652e737667)](https://packagist.org/packages/dlid/cdbyuml) [![Total Downloads](https://camo.githubusercontent.com/14533dac17d3bf99c9a44ea6a81c4fe6b1d202c6061a015b35a20a68e39d0467/68747470733a2f2f706f7365722e707567782e6f72672f646c69642f63646279756d6c2f646f776e6c6f6164732e737667)](https://packagist.org/packages/dlid/cdbyuml) [![Latest Unstable Version](https://camo.githubusercontent.com/59c65563abdcfc6c59f584b48eeb4dd890b480075569eb7a096451442c78786f/68747470733a2f2f706f7365722e707567782e6f72672f646c69642f63646279756d6c2f762f756e737461626c652e737667)](https://packagist.org/packages/dlid/cdbyuml) [![License](https://camo.githubusercontent.com/a1a4c55193cece85cadc110ad4c89685a9c8fd55dd4fc57c6cfc68e6a69310f5/68747470733a2f2f706f7365722e707567782e6f72672f646c69642f63646279756d6c2f6c6963656e73652e737667)](https://packagist.org/packages/dlid/cdbyuml)

CDbYuml
=======

[](#cdbyuml)

CDbYuml will create class diagrams from your PDO sqlite or mysql datasource using [yuml.me](http://yuml.me).

- Flexible so you can use your favorite datasbase access layer
- Easy to use with an existing PDO connection (see example below)

CDbYuml can be used with many other database librariees due to the fact that you will define how the queries are executed:

- CDbYuml will use your callback function to query database for metadata
- CDbYuml will then generate the Yuml string based on the dataase metadata
- The Yuml string is posted to yuml.me and the generated diagram is downloaded

Version
-------

[](#version)

0.2

Tech
----

[](#tech)

CDbYuml has the following requirements:

- [CURL](http://php.net/manual/en/book.curl.php) - The Client URL extension must be enabled in PHP
- [PHP](http://php.net) - tested with PHP 5.4

Note about complex diagrams
---------------------------

[](#note-about-complex-diagrams)

For very large and/or databases this may not be the library you are looking for. It has been tested with simple database structures with a few foreign keys of different kinds.

If the diagram is not generated like you want, you can always send me the generated text and I can try to figure out how to make it compatible.

Options
-------

[](#options)

```
$cdbyuml->setOptions([
 'proxy'        =>   null,       // Proxy address
 'proxyauth'    =>   null,       // Proxy authentication (username:password)
 'query'        =>   null,       // \PDO Object or custom function to fetch data from database
 'sql_dialect'  =>  'sqlite',    // sqlite or mysql. Determines which queries to run
 'style'        =>  'plain',     // Yuml.me styles (plain, scruffy or nofunky)
 'scale'        =>  100,         // Yuml.me scale (100 = 100%)
 'close'        =>  null,        // Optional callback function to close database
 'force'        =>  false,       // Ignore all caching.
 'cachepath'    =>  null,        // Full path to the cachefile
 'cachetime'    =>  '15 minutes' // Maximum time before re-validating database structure
]);
```

Methods
-------

[](#methods)

- **setOptions** ( *$options* ) - Configure the library. See option above
- **outputImage** ( *\[$force = true\]* ) - generate diagram and output the image to the browser
- **outputText** ( *\[$force = true\]* ) - output a HTML page with debug information
- **\_\_construct** ( *$options* ) - Configure the library. Same parameters as setOptions

Sample usage
------------

[](#sample-usage)

In the following example a sqlite database is created with a number of tables.

CDbYuml is then used to generate the diagram of the table.

```
// Open a database connection
$dbh = new PDO('sqlite:mydatabase.sqlite3');

// Initialize CDBYuml
$cdbyuml = new \Dlid\DbYuml\CDbYuml();
$cdbyuml->setOptions([
   'sql_dialect' => 'sqlite',

    // Callback function query the database for metadata
    'query' => function($query, $parameters) use ($dbh) {
        // Pass along query and parameters to our open PDO connection
        $stmt = $dbh->prepare($query);
        $stmt->execute($parameters);
        return $stmt->fetchAll(\PDO::FETCH_ASSOC);
    }
]);

// Fetch metadata from database and generate the YUml string
$cdbyuml->execute()
   #->outputText() // Uncomment to see debug information
   // Output the generated diagram
   ->outputImage();
```

### Alternative ways to do it

[](#alternative-ways-to-do-it)

#### Passing the PDO object as a query

[](#passing-the-pdo-object-as-a-query)

You can also pass your PDO object as the first parameter. Other options can then be set using the second parameter.

```
# Just the PDO:
$cdbyuml->setOptions($dbh);

# Some additional options
$cdbyuml->setOptions($dbh, [ 'proxy' => 'http://some-proxy.example.net:8080' ]);
```

**Note**: Using the method above you can not pass in the 'query' option in the second parameter. The internal function for retreiving data will then be used

#### Using the constructor instead of setOptions

[](#using-the-constructor-instead-of--setoptions)

Finally you can also use the constructor in the very same way as setOptions:

```
# Example passing just the PDO:
$cdbyuml = new \Dlid\DbYuml\CDbYuml([
 'query' => $dbh,
 'cachepath' => '/users/david/temp/cache/dbcache1'
]);
```

Caching
-------

[](#caching)

I recommend using caching for your diagrams. If you do not, then CDbYuml will query your database for it's structure and download a new diagram from yuml.me **every time**. Please cache and everyone will be so, so happy!

```
$cdbyuml->setOptions([
 'cachefile' => '/somepath/db_diagram',
 'cachetime' => '5 minutes'
]);
```

In the above examle, if you specify **cachepath** and **cachetime** two things will happend:

- The yuml text will be saved to the file /somepath/db\_diagram.cache
- The downloaded image will be saved to the file /somepath/db\_diagram.png

The cache will be invalidated if:

- you change the 'style' parameter
- you change the 'scale' parameter
- the cachetime has expired (five minutes since last .cache-file was written)

If 'style' or 'scale' changes, the database structure will be extracted again and a new diagram will be downloaded.

If the cachetime expires then the database will be queried again for it's structure and:

- if the structure has changed, then a new diagram will be downloaded
- otherwise the /somepath/db\_diagram.png image will be used

\##Composer

You can add [dlid/cdbyuml](https://packagist.org/packages/dlid/cdbyuml) to your composer.json file like this.

```
 "require": {
  "dlid/cdbyuml": "dev-master"
 }
```

License
-------

[](#license)

MIT

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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 ~0 days

Total

2

Last Release

4233d ago

Major Versions

0.2 → v1.02014-10-11

### Community

Maintainers

![](https://www.gravatar.com/avatar/4a89f4999424fca1a6fc808b8dddb10a2b0d7b27b767218fa6dccf9db4457d2b?d=identicon)[dlid](/maintainers/dlid)

---

Top Contributors

[![dlid](https://avatars.githubusercontent.com/u/4271305?v=4)](https://github.com/dlid "dlid (30 commits)")

---

Tags

librarymysqlsqlitemoduleumlyuml

### Embed Badge

![Health badge](/badges/dlid-cdbyuml/health.svg)

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

###  Alternatives

[cycle/orm

PHP DataMapper ORM and Data Modelling Engine

1.3k835.4k65](/packages/cycle-orm)[rah/danpu

Zero-dependency MySQL dump library for easily exporting and importing databases

64401.8k10](/packages/rah-danpu)[opis/database

A database abstraction layer over PDO, that provides a powerful and intuitive query builder, bundled with an easy to use schema builder

10184.2k3](/packages/opis-database)[delight-im/db

Safe and convenient SQL database access in a driver-agnostic way

49156.8k7](/packages/delight-im-db)[go/db

Database library

6624.1k](/packages/go-db)[boxed-code/laravel-scout-database

Generic database driver for laravel scout.

1151.7k](/packages/boxed-code-laravel-scout-database)

PHPackages © 2026

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