- Notifications
You must be signed in to change notification settings - Fork0
Expressive fixtures generator
License
stof/alice
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Relying onfzaninotto/Faker, Aliceallows you to create a ton of fixtures/fake data for use while developingor testing your project. It gives you a few essential tools to make itvery easy to generate complex data with constraints in a readable and easyto edit way, so that everyone on your team can tweak the fixtures if needed.
Warning: this doc is for alice 3.0. If you want to check the documentationfor 2.x, headhere.
2.x is in maintenance mode: PRs are accepted, but no active development is done on it by the maintainers any longer.
- Installation
- Example
- Getting Started
- Complete Reference
- Handling Relations
- Keep Your Fixtures Dry
- Customize Data Generation
- Advanced Guide
- Third-party libraries
- Contribute
- Backward Compatibility Promise (BCP)
- Upgrade
Other references:
This is installable viaComposer asnelmio/alice:
composer require --dev nelmio/alice
Here is a complete example of entity declaration:
Nelmio\Entity\User:user{1..10}:username:'<username()>'fullname:'<firstName()> <lastName()>'birthDate:'<date_create()>'email:'<email()>'favoriteNumber:'50%? <numberBetween(1, 200)>'Nelmio\Entity\Group:group1:name:Adminsowner:'@user1'members:'<numberBetween(1, 10)>x @user*'created:'<dateTimeBetween("-200 days", "now")>'updated:'<dateTimeBetween($created, "now")>'
You can then load them easily with:
$loader =newNelmio\Alice\Loader\NativeLoader();$objectSet =$loader->loadFile(__DIR__.'/fixtures.yml');
Or load an array right away:
$loader =newNelmio\Alice\Loader\NativeLoader();$objectSet =$loader->loadData([ \Nelmio\Entity\User::class => ['user{1..10}' => ['username' =>'<username()>','fullname' =>'<firstName()> <lastName()>','birthDate' =>'<date_create()>','email' =>'<email()>','favoriteNumber' =>'50%? <numberBetween(1, 200)>', ], ], \Nelmio\Entity\Group::class => ['group1' => ['name' => Admins,'owner' =>'@user1','members' =>'<numberBetween(1, 10)>x @user*','created' =>'<dateTimeBetween("-200 days", "now")>','updated' =>'<dateTimeBetween($created, "now")>', ], ],]);
For more information, refer tothe documentation.
Check thecontribution guide.
The policy is for the major part following the same asSymfony's one with a few changes orhighlights:
- Code marked with
@private
or@internal
are excluded from the BCP Nelmio\Alice\Loader\NativeLoader
is excluded from the BCP: as it is the no DIC solution, registring a new servicemay require a new method, in which case your code may break if you have already declared that method. To avoid that,please beware of the naming of your methods to avoid any conflicts.
Check theupgrade guide.
About
Expressive fixtures generator
Resources
License
Stars
Watchers
Forks
Packages0
Languages
- PHP99.8%
- Makefile0.2%