solitus0 / alice-generator
Export existing PHP objects and Doctrine entities as reusable Alice fixtures
Requires
- php: ^8.1
- composer-runtime-api: ^2.2
- doctrine/common: *
- doctrine/orm: >=2.14
- jms/metadata: ^2.0
- symfony/property-access: >=5.0
- symfony/yaml: >=5.0
Requires (Dev)
- nelmio/alice: ^3.3
- phpstan/phpstan: ^2.1.6
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- phpunit/phpunit: ^10.0
- rector/rector: ^2.0
- spaze/phpstan-disallowed-calls: ^4.5
- symplify/easy-coding-standard: ^12.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
AliceGenerator is a PHP 8.1+ library that exports existing objects, including Doctrine entities, as reusable Alice fixtures. It preserves shared objects and cycles as named references in the generated YAML.
Generating fixtures from records created through your application's workflows saves time and gives you realistic test data that reflects your business rules and preserves relationships between records.
Quick start
composer require solitus0/alice-generator --dev
Run the PHP quick start to export two tasks that share one assignee. The YAML groups fixtures by fully qualified class name, and both tasks reference the same assignee fixture.
App\Entity\Assignee: Assignee-1: name: Alex App\Entity\Task: Task-1: title: 'Send invoice' assignee: '@Assignee-1' Task-2: title: Review assignee: '@Assignee-1'
Documentation
- Usage covers recursion, object constraints, and collection filters.
- Configuration covers Doctrine, naming, how fixtures are written, and output formats.
- Property transformers replace or redact field values.
- Custom object handlers support value objects that need custom serialization.
- Recipe-based export selects records and fields and validates the YAML before writing it.
- Changelog lists features and migration notes by release.
AliceGenerator is an independently maintained fork of trappar/AliceGenerator. It is released under the MIT License.
