PHPackages                             vcn/symfony-autofactory - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. vcn/symfony-autofactory

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

vcn/symfony-autofactory
=======================

Library that makes it possible to automatically register factory classes in the Symfony Service Container

v0.3.0(2y ago)03.9k↓100%1MITPHPPHP &gt;=7.1

Since Jan 18Pushed 2y ago2 watchersCompare

[ Source](https://github.com/vcn/symfony-autofactory)[ Packagist](https://packagist.org/packages/vcn/symfony-autofactory)[ RSS](/packages/vcn-symfony-autofactory/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (7)Used By (1)

vcn/symfony-autofactory
=======================

[](#vcnsymfony-autofactory)

vcn/symfony-autofactory makes it easy to define service factory classes for Symfony.

Usage
=====

[](#usage)

Please make sure you have a good understanding of how dependency injection works in Symfony. You can find their documentation [here](https://symfony.com/doc/current/service_container.html).

To start using vcn/symfony-autofactory, the easiest approach is to install the vcn/symfony-autofactory-bundle. If you ensure all AutoFactory-instances are autoconfigured, the rest will work automatically.

If you do not want to use the bundle, you need to:

- add the AutoFactoryPass to your kernel compiler passes
- ensure that your AutoFactory-instances all have the tag you configured in the AutoFactoryPass

Usage
=====

[](#usage-1)

Basic usage
-----------

[](#basic-usage)

To create an AutoFactory, create a class that implements the AutoFactory interface. For a class method to be considered a factory it MUST be public, it MUST be static, and it MUST define a class return type.

```
