定制 asvae/laravel-fixtures 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

asvae/laravel-fixtures

Composer 安装命令:

composer require asvae/laravel-fixtures

包简介

README 文档

README

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.

Installation

Install via composer:

composer require asvae/laravel-fixtures

To your App\Console\Kernel add command like this:

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:

$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.

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

FIXTURES_NAMESPACE=App\MyFixtures

Examples

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

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

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

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.

统计信息

  • 总下载量: 20
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-01-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固