Download the PHP package loadsys/cakephp-basic-seed without Composer
On this page you can find all versions of the php package loadsys/cakephp-basic-seed. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package cakephp-basic-seed
CakePHP-Basic-Seed
Provides a simple mechanism for seeding data into your CakePHP application's database.
Requirements
- PHP 5.6+
- CakePHP 3.0+
:warning: Check the cake-2.x branch for the CakePHP v2.x compatible version. The 1.x.x
semver series maintains compatibility with CakePHP 2, while ~2
tracks CakePHP 3.
Installation
Composer
`
Usage
- Add this plugin to your application by adding this line to your
bootstrap.php
:
``
This is a command line plugin. To use it:
`
You can also specify --file
and it will use the file specified (inside of config/
)
`
To create a seed.php
file, run the init
command:
`
To create a seed_dev.php
file:
`
To create a custom seed file, you can use the --file
parameter.
`
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:
Remember that the seed file is just an extension of the BasicSeedShell and that seeds do not have to conform to the above structure. You have access to anything you could normally do from inside a Shell, so for example, this is also a valid seed file:
...although it's worth point out that ::importTables()
performs a more robust version of this exact process for you, including dumping validation errors when they are encountered.
Contributing
Reporting Issues
Please use GitHub Isuses for listing any known defects or issues.
Development
When developing this plugin, please fork and issue a PR for any new development.