littlegiant / silverstripe-seeder
Seed data objects for dev
Installs: 4 982
Dependents: 2
Suggesters: 0
Security: 0
Stars: 19
Watchers: 4
Forks: 8
Type:silverstripe-module
Requires
- fzaninotto/faker: ^1.5
- littlegiant/silverstripe-batchwrite: ~0.3.0
- silverstripe/cms: ~3.1
- symfony/console: ^2.7
This package is auto-updated.
Last update: 2024-11-16 09:18:38 UTC
README
Sick of testing pagination by setting page length to 1 and making two data objects? Look no further!
Features
- Declarative method of generating test data
- Easy to way to share data dependencies with other developers
- Easy to extend
Installation
Installation via composer
composer require littlegiant/silverstripe-seeder
How to use
Add to your configuration
Seeder\Seeder: create: Page: count: 100 fields: Title: 'Hello Seeder! {$i}' Member: member(test@test.com,password)
Change to project root and run
(unix) $ framework/sake seed flush=1
(windows) > php framework/cli-script.php seed flush=1
Command line options
framework/sake seed [-k|--key KEY] [-c|--class CLASS] [-f|--force] [flush=1|all] framework/sake unseed [-k|--key KEY] [flush=1|all]
Providers
Providers are a simple way to customise what data is generated. The seeder comes with a bunch of useful providers
Check here for more information on creating providers
Example
--- Name: seeder --- Seeder\Seeder: create: HomePage: fields: Title: Home Content: > <p>This is an awesome paragraph that can welcome your visitors</p> Blog: fields: Title: Magic in a bottle Member: member(admin@mysite.com,default admin password) --- Name: seeder-dev Only: environment: dev --- Seeder\Seeder: create: - key: Page1 class: Page fields: Title: Parent URLSegment: i-am-a-parent - key: Page2 class: Page fields: Title: Child URLSegment: i-am-a-child Parent: where(Page, URLSegment, i-am-a-parent) Author: count: 10 fields: Name: faker(name) BlogTag: count: 10 BlogPost: count: 100 fields: Parent: first(blog) Author: random() Title: 'Blog post {$i}' Tags: random(BlogTag,3)
License
The MIT License (MIT)
Copyright (c) 2015 Little Giant Design Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Contributing
Pull requests are welcome
Code guidelines
This project follows the standards defined in: