定制 elythyr/prooph-fixtures 二次开发

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

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

elythyr/prooph-fixtures

Composer 安装命令:

composer require elythyr/prooph-fixtures

包简介

First attempt to make something similar to DoctrineFixtures with Prooph

README 文档

README

Build Status Coverage Status

During my experiments with ES I find myself in a situation where Doctrine data fixtures missed me.

Thats why I decided to try to reproduce something similar for Prooph.

Installation

Oh, sweet Composer!

composer require --dev elythyr/prooph-fixtures

Versions management

Since its a practice project, I don't really care about BC breaks. I will only try to not break minor versions, meaning that:

  • Updating from 1.0.0 to 1.0.9 should not break anything
  • Updating from 1.0.0 to 1.1.0 might break a lot of stuff

Configuration

There is no configuration per se. All the configuration should already be done, see Prooph EventStore for more information.

Usage

An example of how to configure the pieces together:

// /test.php

// Configure your system:
// Replace it by your own container or create everything manually :'(
$container = new class() implements ContainerInterface {
    public function has($id) { return false; }
    public function get($id) { return null; }
};

// Retrieve your event store
$eventStore = $container->get('event_store');

// Create a provider for your fixtures
$fixturesProvider = new InMemoryFixturesProvider([
    $youContainer->get('a_fixture'),
    $youContainer->get('another_fixture'),
    // ...
]);

// Retrieve the cleaning projection strategy
// No implementations are provided since it depends on your EventStore implementation
$cleaningProjectionStrategy = $container->get('cleaning_projection_strategy');

// Retrieve the names of all your projections
$projectionsNames = $container->get('projections_names');

// Create the cleaner you want to use, here we will clean both event streams and projections
$cleaner = new ChainCleaner([
    new EventStreamsCleaner($eventStore),
    new ProjectionsCleaner(
        $cleaningProjectionStrategy,
        $projectionsNames
    ),
]);

// Create the fixtures manager, just a front to regroup everything in one place
$fixturesManager = new FixturesManager($fixturesProvider, $cleaner);

// Lets do some cleaning !
$fixturesManager->cleanUp();

// Loading is so easy, you can do it yourself :)
// Under the hood the manager do all the heavy lifting by ordering the fixtures
foreach ($fixturesManager->getFixtures() as $fixture) {
    $fixture->load();
}

Todo

  • Adds CI with Travis
  • Adds tests coverage
  • Make a first release
  • Publish to packagist
  • (When needed) Adds the possibility to not clean the DB
  • (When needed) Adds the possibility to filter the fixtures to load

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-12-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固