Download the PHP package xsolve-pl/model-factory-bundle without Composer
On this page you can find all versions of the php package xsolve-pl/model-factory-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download xsolve-pl/model-factory-bundle
More information about xsolve-pl/model-factory-bundle
Files in xsolve-pl/model-factory-bundle
Package model-factory-bundle
Short Description This bundle provides a versatile skeleton for organizing model factories.
License MIT
Homepage http://github.com/xsolve-pl/xsolve-model-factory-bundle
Informations about the package model-factory-bundle
Table of contents
- Introduction
- License
- Getting started
- Usage examples
- Grouping model factories into collections
Introduction
This bundle wraps xsolve-pl/model-factory library and allows to compose collections of model factories declared as services with the use of tags.
See the library documentation for more details on specific use cases.
License
This bundle is under the MIT license. See the complete license in LICENSE
file.
Getting started
Include this bundle in your Symfony project using Composer as follows (assuming it is installed globally):
For more information on Composer see its Introduction.
Afterwards you need to enable this bundle by adding a line to app/AppKernel.php
file of your project:
That's all - now you're ready to go!
Usage example
Grouping model factories into collections
To make it easy to produce models for multiple objects it is possible to group model factories into collections. If your application provides multiple APIs (or multiple API versions that are so different that they utilize completely different models) you are able to group factories in separate collections and avoid the risk of producing incorrect models.
Grouping model factories into collections is made easier by providing
a dedicated compiler pass that uses tags on model factory service definitions
to inject them into appropriate collections. Consider following example of
services.xml
file:
This snippet defines two model factory collections (with ids
example.model_factory_collection.first
and
example.model_factory_collection.second
respectively). It also defines a
single model factory (with id example.model_factory.foo
). This service has a
tag assigned with name
attribute equal
xsolve.model_factory_bundle.model_factory
(which will result in it being
processed by
Xsolve\ModelFactoryBundle\DependencyInjection\CompilerPass\ModelFactoryCollectionCompilerPass
)
and model-factory-collection-id
attribute containing service ids of
respective collections.
All versions of model-factory-bundle with dependencies
symfony/framework-bundle Version ^2.3|^3.0|^4.0|^5.0|^6.0
xsolve-pl/model-factory Version ^1.0