Download the PHP package zero-to-prod/factory without Composer
On this page you can find all versions of the php package zero-to-prod/factory. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zero-to-prod/factory
More information about zero-to-prod/factory
Files in zero-to-prod/factory
Package factory
Short Description A Generic Factory Pattern for Creating Arrays.
License MIT
Homepage https://github.com/zero-to-prod/factory
Informations about the package factory
Zerotoprod\Factory
Contents
- Introduction
- Requirements
- Installation
- Usage
- The
set()
Method - The
merge()
Method - The
context()
Method
- The
- Local Development
- Contributing
Introduction
A Generic Factory Pattern for Creating Arrays.
Requirements
- PHP 7.1 or higher.
Installation
Install Zerotoprod\Factory
via Composer:
This will add the package to your project’s dependencies and create an autoloader entry for it.
Usage
Define a factory in this way:
The set()
Method
You can use the set()
helper method to fluently modify the state of your model in a convenient way.
This is a great way to modify a model without having to implement a method in the factory.
The merge()
Method
Sometimes it is useful to merge new values into the current context of the factory.
Use the merge()
method to merge any new values and update the factory context.
The context()
Method
Use the context()
method to get the context of the factory.
Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page if you want to contribute.
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Commit changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature-branch
). - Create a new Pull Request.