PHPackages                             brad-denver/paris-seeder - 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. brad-denver/paris-seeder

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

brad-denver/paris-seeder
========================

A simple database seeding class using Faker data and Paris models

v0.0.1(11y ago)139MITPHPPHP &gt;=5.3.3

Since Sep 2Pushed 11y ago1 watchersCompare

[ Source](https://github.com/BradDenver/paris-seeder)[ Packagist](https://packagist.org/packages/brad-denver/paris-seeder)[ Docs](https://github.com/BradDenver/paris-seeder)[ RSS](/packages/brad-denver-paris-seeder/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

paris-seeder
============

[](#paris-seeder)

A simple database seeding class using Faker data and Paris models

Example Syntax

```
Seeder::seed('Seeds\Roles', 2, null, function($record) {
  Seeder::seed('Seeds\Users', 2, array('role_id'=>$record->id));
});
```

The above example would create two roles and two users with each role.

Install and config
------------------

[](#install-and-config)

The easiest way to install paris-seeder and its dependencies ([faker](https://packagist.org/packages/fzaninotto/faker), [idiorm](https://packagist.org/packages/j4mie/idiorm), [paris](https://packagist.org/packages/j4mie/paris)) is via [Composer](https://getcomposer.org/). This class is available through [Packagist](https://packagist.org/packages/brad-denver/paris-seeder) with the vendor and package identifier of `brad-denver/paris-seeder`.

Paris-seeder does not require any configuration itself but the following steps show how to configure Idiorm and setup Paris models for its use.

An example Idiorm config

```
ORM::configure('mysql:host=localhost;dbname=my_database');
ORM::configure('username', 'database_user');
ORM::configure('password', 'top_secret');
```

Examples
--------

[](#examples)

Lets assume we are going to seed a `roles` table

idtitle1Boss2Workerand a `users` table

idnamerole\_id1Sally Hard22Bob Lazy1both with auto incrementing id fields.

### Paris Models

[](#paris-models)

fist we need to create classes for each table that extends the Paris Model class

```
namespace Seeds;

class Roles extends \Model {

  /*
  * use the Paris filter pattern to create a new fake record
  */
  public function create_fake($orm, $faker) {
    $orm->create(array(
      'title' => $faker->word
    ));
    return $orm;
  }
}

class Users extends \Model {

  /*
  * use the Paris filter pattern to create a new fake record
  */
  public function create_fake($orm, $faker) {
    $orm->create(array(
      'name' => $faker->name,
      'role_id' => $faker->randomDigit
    ));
    return $orm;
  }
}
```

The key thing here is that the models have a `create_fake` method that accepts an Idiorm `ORM` instance and `Faker\Generator` instance and returns the record resulting from `$orm->create`.

### Seeder::seed

[](#seederseed)

The seed method expects:

- a paris model instance (or the string/s to create one)
- the count of records to insert (defaults to 1)
- optional data to overide that provided by faker in `create_fake`
- optional callback to be called for record that is inserted (it will be passed the new rocord and the faker instance)
- optional `Faker/Generator` instance to generate fake data (if omitted a new instance will be created) A basic example.

```
Seeder::seed('Seeds\Users', 5);
```

Overide faker data.

```
Seeder::seed('Seeds\Users', 5, array('role_id'=>2));
```

Suppling a callback.

```
Seeder::seed('Seeds\Roles', 2, null, function($record) {
  Seeder::seed('Seeds\Users', 5, array('role_id'=>$record->id));
});
```

Suppling a faker generator

```
$faker = Faker\Factory::create('fr_FR'); // create a French faker
Seeder::seed('Seeds\Users', 5, null, null, $faker);
```

### Seeder::replicate

[](#seederreplicate)

Sometimes there may be no need to use fake data for a certain table. `Seeder::replicate` is helper method to copy all data from one table to another (assuming they have compatible schemas).

```
// a paris model pointing to our production roles table
$source_model = Model::factory('Roles', 'remote');
// a paris model pointing to our dev roles table that needs to mirror production
$target_model = Model::factory('Roles', 'local');
Seeder::replicate($source_model, $target_model);
```

### Seeder::delete\_all

[](#seederdelete_all)

as its name suggests this method simply deletes all records for given models table. It is called as the first step of `Seeder::replicate` and `Seeder::delete_all_and_seed`

```
Seeder::delete_all('Seeds\Users');
```

### Seeder::delete\_all\_and\_seed

[](#seederdelete_all_and_seed)

a helper method for the common use case of deleting and reseeding all data in a table. This method simply calls `Seeder::delete_all` followed by `Seeder:seed` for the given model. It accepts the same arguments as `Seeder:seed`

```
Seeder::delete_all_and_seed('Seeds\Users', 5);
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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

4269d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1479712?v=4)[Brad Denver](/maintainers/BradDenver)[@BradDenver](https://github.com/BradDenver)

---

Top Contributors

[![BradDenver](https://avatars.githubusercontent.com/u/1479712?v=4)](https://github.com/BradDenver "BradDenver (5 commits)")

---

Tags

fakerormseedidiormparis

### Embed Badge

![Health badge](/badges/brad-denver-paris-seeder/health.svg)

```
[![Health](https://phpackages.com/badges/brad-denver-paris-seeder/health.svg)](https://phpackages.com/packages/brad-denver-paris-seeder)
```

###  Alternatives

[j4mie/idiorm

A lightweight nearly-zero-configuration object-relational mapper and fluent query builder for PHP5

2.0k1.5M29](/packages/j4mie-idiorm)[j4mie/paris

A lightweight Active Record implementation for PHP5, built on top of Idiorm

989499.6k22](/packages/j4mie-paris)[theofidry/alice-data-fixtures

Nelmio alice extension to persist the loaded fixtures.

32528.5M70](/packages/theofidry-alice-data-fixtures)[hautelook/alice-bundle

Symfony bundle to manage fixtures with Alice and Faker.

19519.4M34](/packages/hautelook-alice-bundle)[granadaorm/granada

Active Record / ORM with eager loading, lazy loading and more

178.9k1](/packages/granadaorm-granada)

PHPackages © 2026

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