PHPackages                             kristijorgji/db-to-php - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. kristijorgji/db-to-php

ActiveLibrary[Testing &amp; Quality](/categories/testing)

kristijorgji/db-to-php
======================

A library to generate application code based on database definition.

v1.0.4(3y ago)43.5k↓100%MITPHPPHP &gt;=7.1

Since Nov 24Pushed 3y ago1 watchersCompare

[ Source](https://github.com/kristijorgji/db-to-php)[ Packagist](https://packagist.org/packages/kristijorgji/db-to-php)[ RSS](/packages/kristijorgji-db-to-php/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (4)Versions (5)Used By (0)

db-to-php
=========

[](#db-to-php)

A framework for automating PHP code generation for working with databases.

Many times we need data object classes corresponding to different database tables. For testing and populating the databases with dummy data we also require factories which generate dummy/fake data for those tables.

A lot of time is spent doing those tasks manually, so I decided to automate the process. Not only entities and factories are created by this library, but the original type is also detected and used in the classes and in the factory values generator.

For now the library supports only MySql as a database driver.

1. Create entity classes based on your database tables.
2. Create factories for automatic generation of entities with random data, or just random data for tables
3. (Coming soon) Create repositories for writing/reading these entities
4. (Coming soon) Working to support different database drivers aside from MySql

Table of Contents
=================

[](#table-of-contents)

- [Installation](#installation)
- [Config](#config)
- [Usage](#usage)
    - [Generate Entities](#generate-entities)
        - [Instructions](#generate-entities-instructions)
        - [Example execution](#example-entity-generation)
    - [Generate Factories](#generate-factories)
        - [Instructions](#generate-factories-instructions)
        - [Example execution](#example-factory-generation)
- [License](#license)

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

[](#installation)

```
composer require kristijorgji/db-to-php
```

Run the following command to initialize dbToPhp

```
vendor/bin/dbToPhp init
```

This command will create in your project root folder the config file `dbToPhp.cfg.php`You need to edit that to your desired settings.

Config
------

[](#config)

The config and it's keys try to be as much self explanatory as possible. Example config:

```
