family-office / fixtures-library
此包已被弃用且不再维护。未建议替代包。
一个易于使用的 fixture 和依赖项加载库。
1.0.1
2022-01-01 14:31 UTC
Requires
- php: ^8.0
- thecodingmachine/safe: ^1.3
Requires (Dev)
- ergebnis/composer-normalize: ^2.15
- ergebnis/phpstan-rules: ^0.15.3
- phpstan/extension-installer: ^1.1
- phpstan/phpstan: ^0.12.97
- phpstan/phpstan-deprecation-rules: ^0.12.6
- phpstan/phpstan-phpunit: ^0.12.22
- phpstan/phpstan-strict-rules: ^0.12.11
- phpunit/phpunit: ^9.5
- psalm/plugin-phpunit: ^0.16.1
- rector/rector: ^0.11.53
- roave/no-leaks: ^1.3
- roave/security-advisories: dev-latest
- sclable/xml-lint: ^0.4.0
- symfony/thanks: ^1.2
- symplify/easy-coding-standard: ^9.4 || ^10.0
- thecodingmachine/phpstan-safe-rule: ^1.0
- vimeo/psalm: ^4.9
- dev-main
- 1.0.1
- 1.0.0
- 0.4.4
- 0.4.3
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.2
- 0.3.1
- 0.3.0
- 0.2.1
- 0.2.0
- 0.1.0
- dev-dependabot/composer/composer/semver-3.3.2
- dev-dependabot/composer/symfony/polyfill-mbstring-1.25.0
- dev-dependabot/composer/symfony/deprecation-contracts-2.5.1
- dev-dependabot/composer/vimeo/psalm-4.23.0
- dev-dependabot/composer/symfony/finder-5.4.8
- dev-dependabot/composer/symfony/string-5.4.8
This package is auto-updated.
Last update: 2022-05-12 07:31:40 UTC
README
Fixtures Library
一个易于使用的 fixture 和依赖项加载库。
⚠️ 声明:此解决方案是为一个非常特定的用例开发的。在您的用例中加载 fixtures 的最佳方法可能已被 Doctrines 数据 fixtures 覆盖。
❤️ 想要贡献?
安装
composer require family-office/fixtures-library
💡 使用方法
创建 fixture
Fixture 是实现 FixtureInterface 的常规类。
namespace FamilyOffice\FixturesLibrary\Example\Basic\Fixtures; use FamilyOffice\FixturesLibrary\FixtureInterface; final class EarFixture implements FixtureInterface { public function getDependencies(): array { return []; } public function load(): void { // todo: implement data loading } }
所有应在 fixture 中执行的代码都应该放在 load 方法中。
有时,由于必须按特定顺序执行,fixture 需要相互依赖。
fixture 所有的依赖项都应从 getDependencies 方法返回。
namespace FamilyOffice\FixturesLibrary\Example\Basic\Fixtures; use FamilyOffice\FixturesLibrary\FixtureInterface; final class ElephantFixture implements FixtureInterface { public function getDependencies(): array { return [EarFixture::class]; } public function load(): void { // todo: implement data loading } }
加载 fixture
最快速、最简单加载 fixture 的方法是通过创建默认链构建器实例。
$defaultChainBuilder = ChainBuilder::createQuickLoader();
然后,随着依赖项树构建,可以轻松地即时加载 fixture。
$defaultChainBuilder->build([new ElephantFixture()]);
完整示例
完整示例可以在 这里 找到。
高级使用
依赖项链构建和加载过程可以完全根据您的需要进行自定义。
关于此库高级功能的扩展文档可以在 这里 找到。
📝 许可证
此项目在 MIT 许可证下发布。您可以使用代码做任何您想做的事情!