PHPackages                             wavevision/di-service-annotation - 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. [Framework](/categories/framework)
4. /
5. wavevision/di-service-annotation

AbandonedArchivedLibrary[Framework](/categories/framework)

wavevision/di-service-annotation
================================

Register DI services using annotation for Nette Framework.

4.0.1(5y ago)512.1k↓50%2[2 PRs](https://github.com/wavevision/di-service-annotation/pulls)7MITPHPPHP &gt;=7.4

Since Oct 4Pushed 3y ago2 watchersCompare

[ Source](https://github.com/wavevision/di-service-annotation)[ Packagist](https://packagist.org/packages/wavevision/di-service-annotation)[ RSS](/packages/wavevision-di-service-annotation/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (7)Versions (25)Used By (7)

[![Wavevision s.r.o.](https://camo.githubusercontent.com/9479da35305d94b0244ac1c81fe283d0abb86fe217b2a815056165c67c0574e6/68747470733a2f2f77617665766973696f6e2e636f6d2f696d616765732f77617665766973696f6e2d6c6f676f2e706e67)](https://github.com/wavevision)

DIService Annotation
====================

[](#diservice-annotation)

[![CI](https://github.com/wavevision/di-service-annotation/workflows/CI/badge.svg)](https://github.com/wavevision/di-service-annotation/actions/workflows/ci.yml)[![Coverage Status](https://camo.githubusercontent.com/cb19886e757a5a4188fa5233c2d99c65c748ee736d959f807d45c04249ebeb0f/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f77617665766973696f6e2f64692d736572766963652d616e6e6f746174696f6e2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/wavevision/di-service-annotation?branch=master)[![PHPStan](https://camo.githubusercontent.com/027fd636e970cf392fd4478baf3261048b41955d2905a95fb47da6bf19b8640a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374796c652d6c6576656c2532306d61782d627269676874677265656e2e7376673f6c6162656c3d7068707374616e)](https://github.com/phpstan/phpstan)

Helper for registering Nette DI services via Doctrine Annotations, factory generator and inject generator.

Install
-------

[](#install)

```
composer require --dev wavevision/di-service-annotation

```

> **Note:** Install [phpstan-nette](https://github.com/phpstan/phpstan-nette) if you need support for strict return types.

Usage
-----

[](#usage)

### Annotate your service

[](#annotate-your-service)

```
use Wavevision\DIServiceAnnotation\DIService;

/**
 * @DIService(params={"%wwwDir%"}, generateInject=true, generateFactory=true)
 */
class ExampleService
{

}
```

### Create runner script

[](#create-runner-script)

For example `bin/extract-services.php`

```
use Wavevision\DIServiceAnnotation\Configuration;
use Wavevision\DIServiceAnnotation\Runner;

Runner::run(new Configuration('sourceDirectory', 'services.neon'));
```

Running this script with `php bin/extract-services.php`

will generate from [class](tests/DIServiceAnnotationTests/Services/Nested/ExampleService.php) following:

- [factory](tests/DIServiceAnnotationTests/expected/Services/Nested/ExampleServiceFactory.php)
- [inject](tests/DIServiceAnnotationTests/expected/Services/Nested/InjectExampleServiceFactory.php)
- [neon config](tests/DIServiceAnnotationTests/expected/nested.neon#L5)

### Annotation options

[](#annotation-options)

- `enableInject: bool` – will add `inject: on` to generated service config (default `true`)
- `generateComponent: bool` – will generate `Component` trait, with factory and `createComponent` implemented
- `generateFactory: bool` – will generate `Factory` interface with `create` function
- `generateInject: bool` – will generate `Inject` trait with property `$` and `inject` function implemented
- `params: string[]` – list of DI parameters to be passed to service constructor
- `tags: string[]` – list of tags to be used with the service in generated config

For configuration options see [Configuration properties](src/DIServiceAnnotation/Configuration.php#L7).

### Configuration option

[](#configuration-option)

#### Required

[](#required)

- `sourceDirectory: string` – location of services
- `outputFile: string` – output file for registered services

#### Optional

[](#optional)

- `setMask: string` – mask for file locator - default `*.php`
- `setFileMapping: array` – map for splitting configs by namespace

```
$configuration->setFileMapping([
    'RootNamespace\Namespace1' => 'config1.neon',
    'RootNamespace\Namespace2' => 'config2.neon',
]);
```

- `setInjectGenerator: Inject` – set custom generator for injects
- `setFactoryGenerator: Factory` – set custom generator for factories
- `setComponentFactory: Component` – set custom generator for components
- `setRegenerate: bool` – regenerate all generated code each run - default `false`
- `enableFileValidation` – check each file for fatal errors before reading annotation, skip file on error
    - `autoloadFile: string` – file for class autoloading, e.g. `vendor/autoload.php`
    - `tempDir: string` – enable cache, directory for cache file, only changed files are validated

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 60.5% 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 ~19 days

Recently: every ~63 days

Total

21

Last Release

2035d ago

Major Versions

1.1.0 → 2.0.02019-10-19

2.1.3 → 3.0.02019-12-12

3.2.0 → 4.0.02020-03-31

PHP version history (2 changes)1.0.0PHP &gt;=7.2

3.0.1PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/3af21e3a334be19fe9e3355c0d300a8a41e63322103aa24929e745d7cac6c965?d=identicon)[rozsival](/maintainers/rozsival)

![](https://www.gravatar.com/avatar/64a880caaffe510a647f7ae7da515846fc661fe10744b17a981ddbc47bbae4df?d=identicon)[jfilla](/maintainers/jfilla)

---

Top Contributors

[![jfilla](https://avatars.githubusercontent.com/u/5280477?v=4)](https://github.com/jfilla "jfilla (46 commits)")[![rozsival](https://avatars.githubusercontent.com/u/7785240?v=4)](https://github.com/rozsival "rozsival (29 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (1 commits)")

---

Tags

annotationdependency-injectionfactoriesinjectsnette

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wavevision-di-service-annotation/health.svg)

```
[![Health](https://phpackages.com/badges/wavevision-di-service-annotation/health.svg)](https://phpackages.com/packages/wavevision-di-service-annotation)
```

###  Alternatives

[goaop/framework

Framework for aspect-oriented programming in PHP.

1.7k4.0M33](/packages/goaop-framework)[shopware/shopware

Shopware 5 is an open source e-commerce software made in Germany

1.3k746.6k35](/packages/shopware-shopware)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[neos/flow

Flow Application Framework

862.0M451](/packages/neos-flow)[oro/platform

Business Application Platform (BAP)

644134.8k84](/packages/oro-platform)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

7310.3k29](/packages/open-dxp-opendxp)

PHPackages © 2026

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