PHPackages                             tacno/populate-mysql-db - 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. tacno/populate-mysql-db

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

tacno/populate-mysql-db
=======================

117[1 issues](https://github.com/tokenpost/populate-mysql-db/issues)PHP

Since Jan 24Pushed 8y ago1 watchersCompare

[ Source](https://github.com/tokenpost/populate-mysql-db)[ Packagist](https://packagist.org/packages/tacno/populate-mysql-db)[ RSS](/packages/tacno-populate-mysql-db/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Populate Database (Works only for mysql)
========================================

[](#populate-database-works-only-for-mysql)

This class populate the table in database with random values. In some cases, we need to view an application with data and this class solve this problem.

Requirements
------------

[](#requirements)

- PDO
- PHP &gt;= 5.3

How to install:
---------------

[](#how-to-install)

You need to use the composer:

```
{
	"require": {
		"tokenpost/populate-mysql-db": "dev-master"
	}
}
```

How to usage:
-------------

[](#how-to-usage)

The class Populate generate random numbers for:

- int
- bigint
- mediumint
- smallint
- tinyint
- float
- double

and generate texts for

- varchar
- text

There is a class to generate Lorem impsum texts.

If you want to change a fix value instead a lorem ipsum generator, you can use the method `->setFixValue('','');`.

```
// Example:
....
$populate->setFixValue('image_field','/assets/image/photo.png');
```

An example
----------

[](#an-example)

Paragraphs are separated by a blank line.

```
try {

	$pdo = new PDO("mysql:host=localhost;dbname=test;charset=utf8",'root','');

	$populate = new Populate();
	$populate->beginWithLoremIpsum(false); // If you want the text beginning with lorem ipsum
	$populate->setPDO($pdo); // set the PDO class

	$populate->setTable('table_test'); // Set the table to populate
	$populate->setFixValue('image_example','/assets/image/photo.jpg'); // if you want a fix value
	echo $populate->insert(100); // The number of inserts
}
catch(Exception $e)
{
	echo $e->getMessage();
}
```

Another Example
---------------

[](#another-example)

```
$pdo = new PDO("mysql:host=localhost;dbname=test;charset=utf8",'root','');

$populate = new Populate();
$populate->beginWithLoremIpsum(false); // If you want the text beginning with lorem ipsum
$populate->setPDO($pdo); // set the PDO class

$populate->setTable('table_test'); // Set the table to populate
$populate->setFixValue('image_example','/assets/image/photo.jpg'); // if you want a fix value
echo $populate->clean(); // Truncate the table
```

You can execute via php cli or task.

Extra
-----

[](#extra)

If you want, you can use the Lorem Ipsum generator in your projects. The class Populate\\LoremIpsumGenerator use the Singleton like a design pattern.

An example:

```
$lorem = \Populate\LoremIpsumGenerator::getInstance();

// If u want to generate by a number of words
echo $lorem->generateByWords(30);

// If u want to generate by a number of chars
echo $lorem->generateByChars(30);

// If u want to generate by a paragraph number. The second parameter is if you want to separe by html (tag: )
echo $lorem->generateByParagraph(2,true);

// And if u want to generate a random word
echo $lorem->generateRandomWord();
```

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/904dffc09e9e7060ed4a1b5bb5023e100f0a723240e2bd14a5324cd9d184a675?d=identicon)[Tacnoman](/maintainers/Tacnoman)

---

Top Contributors

[![renatocassino](https://avatars.githubusercontent.com/u/5348316?v=4)](https://github.com/renatocassino "renatocassino (39 commits)")

### Embed Badge

![Health badge](/badges/tacno-populate-mysql-db/health.svg)

```
[![Health](https://phpackages.com/badges/tacno-populate-mysql-db/health.svg)](https://phpackages.com/packages/tacno-populate-mysql-db)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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