trappar / alice-generator
Automatically generates alice fixture based on a set of objects
Installs: 182 626
Dependents: 1
Suggesters: 0
Security: 0
Stars: 51
Watchers: 3
Forks: 20
Open Issues: 9
Requires
- php: ^7.1
- doctrine/common: ^2.6
- jms/metadata: ^1.5
- symfony/yaml: ^2.8||^3.0|^4.0
Requires (Dev)
- doctrine/orm: ^2.6
- nelmio/alice: ^3.3
- phpunit/phpunit: ^7.1
This package is auto-updated.
Last update: 2024-10-20 06:31:45 UTC
README
Recursively convert existing objects into Alice Fixtures.
Introduction
Sometimes you find yourself working on a large project with no existing fixtures. In this case even though Alice makes fixtures much easier to write, that process can still be tedious.
This library proposes an alternate starting point - automatically generate fixtures from your existing data.
This opens up a whole new, much faster way to get your test data established... just enter it in your user interface!
Example
Let's say you have the following objects
<?php class Post { public $title; public $body; public $postedBy; } class User { public $username; } $user = new User(); $user->username = 'Trappar'; $post1 = new Post(); $post1->title = 'Is Making Fixtures Too Time Consuming?'; $post1->body = 'Check out Alice!'; $post1->postedBy = $user; $post2 = new Post(); $post2->title = 'Too Much Data to Hand Write?'; $post2->body = 'Check out AliceGenerator!'; $post2->postedBy = $user;
This library let's you turn that directly into...
Post: Post-1: title: 'Is Making Fixtures Too Time Consuming?' body: 'Check out Alice!' postedBy: '@User-1' Post-2: title: 'Too Much Data to Hand Write?' body: 'Check out AliceGenerator!' postedBy: '@User-1' User: User-1: username: Jeff
Installation
You can use Composer to install the library to your project:
composer require trappar/alice-generator
Features
- Framework support
- Supports Symfony via AliceGeneratorBundle - Start generating fixtures immediately with zero custom code required!
- ORM support
- Supports Doctrine natively
- Can operate without any ORM
- Can be extended to support any ORM
- Many ways to make use of Faker providers
- Configure how your objects are serialized using annotations or YAML metadata
- Can serialize any object type using custom ObjectHandlers
- Supports multiple levels of recursion taming
- Handles circular references automatically
- Customizable maximum recursion depth
- Can restrict object traversal to only specific objects of a type
- Supports several methods of naming Alice references natively - fully customizable
Table of Contents
Resources
Credits
This bundle was developed by Jeff Way with quite a lot of inspiration from: