PHPackages                             loadsys/cakephp-basic-seed - 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. loadsys/cakephp-basic-seed

ActiveCakephp-plugin[Testing &amp; Quality](/categories/testing)

loadsys/cakephp-basic-seed
==========================

Provides a simple mechanism for seeding data into a CakePHP application's database.

2.1.1(10y ago)482.2k↓28.6%1[3 issues](https://github.com/loadsys/CakePHP-Basic-Seed/issues)[1 PRs](https://github.com/loadsys/CakePHP-Basic-Seed/pulls)MITPHPPHP &gt;=5.4.16

Since Jun 30Pushed 7y ago9 watchersCompare

[ Source](https://github.com/loadsys/CakePHP-Basic-Seed)[ Packagist](https://packagist.org/packages/loadsys/cakephp-basic-seed)[ Docs](http://github.com/loadsys/CakePHP-Basic-Seed)[ RSS](/packages/loadsys-cakephp-basic-seed/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (2)Versions (14)Used By (0)

CakePHP-Basic-Seed
==================

[](#cakephp-basic-seed)

[![Latest Version](https://camo.githubusercontent.com/9680de0631ce87fd1f77f30cf3c8515c6b375f2750428e176358de8ab0d1f106/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6c6f61647379732f43616b655048502d42617369632d536565642e7376673f7374796c653d666c61742d737175617265)](https://github.com/loadsys/CakePHP-Basic-Seed/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/3d1a415bda28be6f8b0015df4bd659e20c8ce9f624b77f24413754b4d8cba93b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c6f61647379732f63616b657068702d62617369632d736565642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/loadsys/cakephp-basic-seed)

Provides a simple mechanism for seeding data into your CakePHP application's database.

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

[](#requirements)

- PHP 5.6+
- CakePHP 3.0+

⚠️ Check the [cake-2.x branch](https://github.com/loadsys/CakePHP-Basic-Seed/tree/cake-2.x) for the CakePHP v2.x compatible version. The `1.x.x` semver series maintains compatibility with CakePHP 2, while `~2` tracks CakePHP 3.

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

[](#installation)

### Composer

[](#composer)

```
$ composer require loadsys/cakephp-basic-seed:~2.0
```

Usage
-----

[](#usage)

- Add this plugin to your application by adding this line to your `bootstrap.php`:

```
Plugin::load('BasicSeed', ['bootstrap' => false, 'routes' => false]);
```

This is a command line plugin. To use it:

```
bin/cake BasicSeed.basic_seed
# Runs the `config/seed.php` seed file.

# or
bin/cake BasicSeed.basic_seed --dev
# Runs `config/seed_dev.php` seed file.
```

You can also specify `--file` and it will use the file specified (inside of `config/`)

```
bin/cake BasicSeed.basic_seed --file seed_staging.php
# Will use the file located at `config/seed_staging.php`.
# This option always overrides --dev.
```

To create a `seed.php` file, run the `init` command:

```
bin/cake BasicSeed.basic_seed init
```

To create a `seed_dev.php` file:

```
bin/cake BasicSeed.basic_seed init --dev
```

To create a custom seed file, you can use the `--file` parameter.

```
bin/cake BasicSeed.basic_seed init --file seed_staging.php
```

Writing a Seed
--------------

[](#writing-a-seed)

The plugin provides a number of helper methods to help get data into your application more efficiently. The most notable of these is `$this->importTables($data)`. This method takes an array structure and iterates over it, converting the array data into Entities and saving them into each named table. The generate structure of the array is as follows:

```
