定制 stwarog/fuel-fixtures-generator 二次开发

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

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

stwarog/fuel-fixtures-generator

Composer 安装命令:

composer require stwarog/fuel-fixtures-generator

包简介

Generator for fuel fixtures package

README 文档

README

This is a package that helps to generate Fuel Fixture package implementation.

Development

make start # starts the local env
make check # calls all tests including statis analysis
  make cs
  make phpstan
  make unit
  make integration

Usage

# The best approach is using some DI container implementation and fetch the service from there:

use Stwarog\FuelFixturesGenerator\{Config as FixtureGeneratorConfig,
    Factory as FixtureChunkFactory,
    FixtureFactory,
    FuelAwareNameGenerator,
    NameGenerator,
    Renderer\Engine,
    Renderer\Engine as FixtureGeneratorViewEngine,
    Renderer\File,
    Renderer\Service as Generator,
    Renderer\Storage};

# e.g. entry configuration

return [
    NameGenerator::class => fn(Container $c) => new FuelAwareNameGenerator($c->get(FixtureGeneratorConfig::class)),

    Storage::class => fn(Container $c) => new File(),

    FixtureChunkFactory::class => fn(Container $c) => new FixtureFactory(
        $c->get(NameGenerator::class),
        $c->get(FixtureGeneratorConfig::class)
    ),

    // Adapter for Twig of Fixture Generator Engine
    FixtureGeneratorViewEngine::class => function (Container $c): Engine {
        return new class ($c->get(TwigViewRenderer::class)) implements FixtureGeneratorViewEngine {

            private ViewRendererContract $renderer;

            public function __construct(TwigViewRenderer $renderer)
            {
                $this->renderer = $renderer;
            }

            public function render(string $fileName, array $params = []): string
            {
                return $this->renderer->render('fixture.twig', $params);
            }
        };
    },

    FixtureGeneratorConfig::class => function (Container $c): FixtureGeneratorConfig {
        return new class () implements FixtureGeneratorConfig {

            public function getNameSpace(): string
            {
                return 'Tests\Fixtures';
            }

            public function storagePath(): string
            {
                return APPPATH . 'tests/fixtures/';
            }

            public function outputTemplate(): string
            {
                return 'fixture.twig';
            }
        };
    },

    Generator::class => fn(Container $c) => new Generator(
        $c->get(FixtureChunkFactory::class),
        $c->get(FixtureGeneratorViewEngine::class),
        $c->get(Storage::class),
        $c->get(FixtureGeneratorConfig::class),
    ),
];

Important

This package needs some Templating Engine. In integration tests can be found an example with Twig.

There is no implementation of usage in CLI as Fuel autoload system is really challenging. Fetch Service and call method to generate the file.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-02-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固