Giter Club home page Giter Club logo

cakephp-fake-seeder's Introduction

CakePHP Fake Seeder

Travis-CI Build Status Coverage Status Scrutinizer Code Quality Total Downloads Latest Stable Version

A CakePHP shell to seed your database with fake and/or fixed data.

Uses Faker to generate the fake data. Uses shell tasks for implementing specific seeders. Organizes logical groups of seeders in custom seeder shells/suites.

Why should I use it?

You are wondering why you should use this plugin instead of using Faker directly or creating fake data on your own?

This plugin...

  • keeps you from doing the repetitive work (DRY)
  • provides you three working modes (manual faking to fully automatic guessing)
  • helps you to stick to conventions, by following CakePHP's "Convention over Configuration" principle
  • still provides you flexible configuration
  • reduces documentation needs
  • is properly covered by unit tests
  • is easy to learn
  • is extensible

Installation

Requirements

  • PHP >= 5.4
  • CakePHP 2.x (tested with 2.6.2, 2.7.3)

Installation via composer

composer require ravage84/cakephp-fake-seeder

Installation alternatives

Refer to the CakePHP CookBook section How To Install Plugins.

CakePHP Version Support

This plugin only supports CakePHP 2.x.

Versioning

The releases of this plugin are versioned using SemVer.

Configuration

Set the configuration key FakeSeeder.seedable to true, by adding Configure::write('FakeSeeder.seedable', true); to your boostrap code.

How to use

After installing and configuring the plugin, you can invoke the shell by executing php Console/cake.php FakeSeeder.seeder -h.

Welcome to CakePHP v2.6.2 Console
---------------------------------------------------------------
App : app
Path: D:\dev\xampp\htdocs\cate\app\
---------------------------------------------------------------
A shell to seed your database with fake and/or fixed data.

Uses Faker to generate the fake data.
Uses shell tasks for implementing specific seeders.
Organizes logical groups of seeders in custom seeder shells/suites.

Usage:
cake fake_seeder.seeder [options] [<model>]

Options:

--help, -h         Display this help.
--verbose, -v      Enable verbose output.
--quiet, -q        Enable quiet output.
--mode, -m         The seeding mode.
                   'manual' = No Field formatters are guessed.
                   'auto' = All field formatters are guessed.
                   'mixed' = Only missing field formatters are guessed.
                   (choices: manual|auto|mixed)
--locale, -l       The locale to use for Faker.
--records, -r      The amount of records to seed.
--validate         Whether or not to validate when saving the seeding
                   data. (choices: first|1|)
--seed, -s         Set the seed number for Faker to use.
--no-truncate      Prevents that the model gets truncated before
                   seeding.

Arguments:

model  The name of a seeder shell task without 'SeederTask' suffix.
       For example 'Article' for 'ArticleSeederTask'.
       Alternatively the name of a model.
       It will try to guess the field formatters then.
       (optional)

All shell options can be set through:
1. CLI parameter, e.g. "--records"
2. The seeder specific configuration, e.g. "FakeSeeder.Article.records"
3. The general seeder configuration, e.g "FakeSeeder.records"
4. The seeder shell task class properties, e.g. "$_records"
The values are checked in that order. The first value found is taken.
If no value is set, it will fall back to an optional default value.

When no seeders are set (e.g. in a custom seeder suite) and if called
without arguments, it will prompt to execute one of the seeder shell
tasks available.

Contributing

See CONTRIBUTING.md

Changelog

See CHANGELOG.md

TODOs

  • Improve Documentation
  • Simplify integration of 3rd party data provider
  • Implement seeder shell task baking
  • Check possibility to use code for TestFixtures, like gourmet/faker

License

This plugin is licensed under the MIT License.

Attribution

This project was inspired by the works of others, such as:

cakephp-fake-seeder's People

Contributors

d4rkmindz avatar ravage84 avatar tekkcraft avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

cakephp-fake-seeder's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.