2017 © Pedro Peláez
 

library laravel-fixtures

image

asvae/laravel-fixtures

  • Wednesday, January 25, 2017
  • by asvae
  • Repository
  • 1 Watchers
  • 6 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Intention

When working with database, sometimes we need to modify schema, and sometimes data. Doing both things in laravel migrations is painful. This package gives simple means to keep two of them separately., (*1)

Installation

Install via composer:, (*2)

composer require asvae/laravel-fixtures

To your App\Console\Kernel add command like this:, (*3)

protected $commands = [
    // ...

    \Asvae\LaravelFixtures\Commands\FixtureRun::class,
];

Usage

For your fixtures be sure to extend\Asvae\LaravelFixtures\AbstractFixture class or at least implement Asvae\LaravelFixtures\FixtureContract. Abstract class has several utility methods to keep you going:, (*4)

$this->runFixture($className); // Runs another fixture.
$this->runArray($className); // Run [nested] array of fixtures

To run fixture do php artisan fixture:run "\App\Fixtures\YourFixture". This will basically run run method in given class, while also resolving dependencies in case you defined any in constructor., (*5)

Config

No config file provided as the library is way too small. You can define default namespace in .env file though. This will be used when you pass class name without namespace, (*6)

FIXTURES_NAMESPACE=App\MyFixtures

Examples

Take a look at several examples. For the case depicted, in production, to fully migrate data you will run, (*7)

php artisan fixture:run "\Asvae\LaravelFixtures\Examples\FixtureSet"

In development, to refresh single table you will run solitary fixtures as these are much faster., (*8)

Hints

  • You can copy namespaced class name in PHPStorm by placing cursor onto class name and pressing Ctrl (⌘) + Shift + Alt + C
  • If you want to add some functionality, feel free to just copy package in your project. Several classes won't hurt.
  • Spread a word or leave a star if what I did was helpful for you.

The Versions

25/01 2017

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

by Yauheni Prakopchyk

database laravel migrations

25/01 2017

0.1.2

0.1.2.0

  Sources   Download

MIT

The Requires

 

by Yauheni Prakopchyk

database laravel migrations

25/01 2017

0.1.0

0.1.0.0

  Sources   Download

MIT

The Requires

 

by Yauheni Prakopchyk

database laravel migrations

25/01 2017

0.1.1

0.1.1.0

  Sources   Download

MIT

The Requires

 

by Yauheni Prakopchyk

database laravel migrations

25/01 2017

0.0.2

0.0.2.0

  Sources   Download

MIT

The Requires

 

by Yauheni Prakopchyk

database laravel migrations