PHPackages                             aeviiq/factory - 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. aeviiq/factory

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

aeviiq/factory
==============

Service Factory Component

v3.2.1(5y ago)57.1k2MITPHPPHP ^7.2

Since May 31Pushed 5y ago1 watchersCompare

[ Source](https://github.com/aeviiq/factory)[ Packagist](https://packagist.org/packages/aeviiq/factory)[ Docs](https://github.com/aeviiq/factory)[ RSS](/packages/aeviiq-factory/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (2)Versions (17)Used By (0)

Dependency Injection Factory Component
======================================

[](#dependency-injection-factory-component)

Why
---

[](#why)

To enable you to create service based factories rapidly, without having to configure anything outside the factory, as the factory itself always knows what it will return, and thus 'requires' in order to do so. This becomes especially useful when combined with the Symfony autowiring functionality, as the only method you will need is the getTargetInterface() for everything to be done automatically.

Installation
------------

[](#installation)

```
composer require aeviiq/factory

```

##### Symfony &gt;= 4

[](#symfony--4)

```
// src/Kernel.php
namespace App;

use Aeviiq\Factory\FactoryCompilerPass;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;

class Kernel extends BaseKernel
{
    use MicroKernelTrait;

    // ...

    protected function build(ContainerBuilder $container): void
    {
        $container->addCompilerPass(new FactoryCompilerPass());
    }
}
```

##### Symfony &lt; 4

[](#symfony--4-1)

```
// src/AppBundle/AppBundle.php
namespace AppBundle;

use Aeviiq\Factory\FactoryCompilerPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class AppBundle extends Bundle
{
    public function build(ContainerBuilder $container)
    {
        parent::build($container);

        $container->addCompilerPass(new FactoryCompilerPass());
    }
}
```

Declaration
-----------

[](#declaration)

```
final class EncoderFactory extends AbstractServiceFactory
{
    public function getEncoder(User $user): Encoder
    {
        // getOneBy ensures 1, and only 1 encoder is returned.
        // In case multiple encoders (or none) are found, a LogicException will be thrown.
        // In case the result is optional, you could use the getOneOrNullBy().
        return $this->getOneBy(static function (Encoder $encoder) use ($user) {
            return $encoder->supports($user);
        });
    }

    protected function getTargetInterface(): string
    {
        // All services with this interface will automatically be wired to the factory
        // without needing any additional service configuration.
        // Using autowire these few lines are all you would need to implement your factory.
        return Encoder::class;
    }
}
```

Usage
-----

[](#usage)

```
final class Foo
{
    /**
     * @var FactoryInterface
     */
    private $encoderFactory;

    public function __construct(FactoryInterface $encoderFactory)
    {
        $this->encoderFactory = $encoderFactory;
    }

    public function authenticateUser(User $user): void
    {
        // ...
        $encoder = $this->encoderFactory->getEncoder($user);
        if (!$encoder->isValidPassword($user->getPassword, $presentedPassword, $user->getSalt())) {
            // ...
        }
        // ...

    }
}
```

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 92.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~50 days

Recently: every ~139 days

Total

16

Last Release

1827d ago

Major Versions

v1.0.2 → v2.02019-07-05

2.0.x-dev → 3.0.x-dev2019-07-09

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/34397049?v=4)[aeviiq](/maintainers/aeviiq)[@aeviiq](https://github.com/aeviiq)

---

Top Contributors

[![aeviiq](https://avatars.githubusercontent.com/u/34397049?v=4)](https://github.com/aeviiq "aeviiq (35 commits)")[![nusje2000](https://avatars.githubusercontent.com/u/17175959?v=4)](https://github.com/nusje2000 "nusje2000 (2 commits)")[![dbrekelmans](https://avatars.githubusercontent.com/u/9531344?v=4)](https://github.com/dbrekelmans "dbrekelmans (1 commits)")

---

Tags

factory

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aeviiq-factory/health.svg)

```
[![Health](https://phpackages.com/badges/aeviiq-factory/health.svg)](https://phpackages.com/packages/aeviiq-factory)
```

###  Alternatives

[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

101466.4k45](/packages/friendsoftypo3-content-blocks)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
