PHPackages                             mhd-jalilvand/php-dbml-parser - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. mhd-jalilvand/php-dbml-parser

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

mhd-jalilvand/php-dbml-parser
=============================

PHP Parser for database markup language (dbml)

1.0.3(6y ago)229MITPHPPHP ^7.0

Since Feb 12Pushed 6y ago2 watchersCompare

[ Source](https://github.com/mhd-jalilvand/php-dbml-parser)[ Packagist](https://packagist.org/packages/mhd-jalilvand/php-dbml-parser)[ RSS](/packages/mhd-jalilvand-php-dbml-parser/feed)WikiDiscussions master Synced 4w ago

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

php-dbml-parser
===============

[](#php-dbml-parser)

Parse database markup language (DBML)

You can use [Diagram.io](https://dbdiagram.io/) to visually design your database diagram and write down the codes in a file and parse it using this script to parse it.

Installation &amp; sample codes
-------------------------------

[](#installation--sample-codes)

```
composer require mhd-jalilvand/php-dbml-parser
cp  vendor/mhd-jalilvand/php-dbml-parser/example.php example.php
cp  vendor/mhd-jalilvand/php-dbml-parser/tests -r tests
php  example.php
phpunit tests/ParserTest.php

```

Usage
-----

[](#usage)

tests/test.dbml contains a sample database schema as:

```
table posts {
  id int [pk, increment]
  title varchar [not null]
}

table comments {
  id int [pk,increment]
  comment varchar
  post_id int [not null,ref: > posts.id]
}
table tags{
  id int [pk, increment, not null]
  title varchar [not null]
}

table post_tags{
  id int [pk]
  post_id int
  tag_id int
}

Ref: "tags"."id" < "post_tags"."tag_id"

Ref: "posts"."id" < "post_tags"."post_id"

```

Example code:

```
