2017 © Pedro Peláez
 

silverstripe-module silverstripe-seeder

Seed data objects for dev

image

littlegiant/silverstripe-seeder

Seed data objects for dev

  • Tuesday, February 21, 2017
  • by stevie-mayhew
  • Repository
  • 5 Watchers
  • 20 Stars
  • 3,931 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 8 Forks
  • 5 Open issues
  • 8 Versions
  • 3 % Grown

The README.md

SilverStripe Seeder

Sick of testing pagination by setting page length to 1 and making two data objects? Look no further!, (*1)

Features

  • Declarative method of generating test data
  • Easy to way to share data dependencies with other developers
  • Easy to extend

Installation

Installation via composer, (*2)

``` bash composer require littlegiant/silverstripe-seeder, (*3)


# How to use Add to your configuration ``` yaml Seeder\Seeder: create: Page: count: 100 fields: Title: 'Hello Seeder! {$i}' Member: member(test@test.com,password)

Change to project root and run, (*4)

``` bash (unix) $ framework/sake seed flush=1 (windows) > php framework/cli-script.php seed flush=1, (*5)


## Command line options ``` bash framework/sake seed [-k|--key KEY] [-c|--class CLASS] [-f|--force] [flush=1|all] framework/sake unseed [-k|--key KEY] [flush=1|all]
Option Description
--force run the seeder ignoring current records
--key only (un)seed records matching this key
--class only seed records for this root class
flush useful silverstripe CliController arg that flushes configuration

Providers

Providers are a simple way to customise what data is generated. The seeder comes with a bunch of useful providers, (*6)

Provider Description Example
ValueProvider Use the given value, select variables included Field: 'this is the value'
DateProvider Generate a date Field: date(+3 months)
FakerProvider Generate data using the php faker library Field: faker(sentences,3)
FirstObjectProvider Returns the first instance of the class Parent: first(Page)
RandomObjectProvider Returns a list of random objects for class Children: random(Page)
HTMLProvider Returns random HTML Field: html()
ImageProvider Returns an Image of a placehold.it image Image: image(300,400)
MemberProvider Returns a member with email and password Member: member(test@test.com,password)
WhereProvider Returns a DataObject with matching field value Parent: where(Page, URLSegment, i-am-a-parent)

Check here for more information on creating providers, (*7)

Example

``` yaml

Name: seeder

Seeder\Seeder: create: HomePage: fields: Title: Home Content: >, (*8)

This is an awesome paragraph that can welcome your visitors, (*9)

    Blog:
        fields:
            Title: Magic in a bottle
    Member: member(admin@mysite.com,default admin password)

Name: seeder-dev Only:, (*10)

environment: dev

Seeder\Seeder: create: - key: Page1 class: Page fields: Title: Parent URLSegment: i-am-a-parent, (*11)

    -
        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)

```, (*12)

License

The MIT License (MIT), (*13)

Copyright (c) 2015 Little Giant Design Ltd, (*14)

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:, (*15)

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software., (*16)

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., (*17)

Contributing

Pull requests are welcome, (*18)

Code guidelines

This project follows the standards defined in:, (*19)

The Versions

21/02 2017

dev-master

9999999-dev http://github.com/Little-Giant/silverstripe-seeder

Seed data objects for dev

  Sources   Download

MIT

The Requires

 

by Chris Barrett

silverstripe seed developer tool

21/02 2017
21/12 2015
26/11 2015

dev-bugfixes-1.0.2

dev-bugfixes-1.0.2 http://github.com/Little-Giant/silverstripe-seeder

Seed data objects for dev

  Sources   Download

MIT

The Requires

 

by Chris Barrett

silverstripe seed developer tool

26/11 2015
24/11 2015
24/11 2015

dev-post-1.0-bugfixes

dev-post-1.0-bugfixes http://github.com/Little-Giant/silverstripe-seeder

Seed data objects for dev

  Sources   Download

MIT

The Requires

 

by Chris Barrett

silverstripe seed developer tool

15/10 2015

1.0.0

1.0.0.0 http://github.com/Little-Giant/silverstripe-seeder

Seed data objects for dev

  Sources   Download

BSD-2-Clause

The Requires

 

by Little Giant

silverstripe seed developer tool