PHPackages                             navarr/dependency-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. navarr/dependency-annotation

ActiveComposer-plugin[Utility &amp; Helpers](/categories/utility)

navarr/dependency-annotation
============================

Adds extra functionality for interpreting the @dependency annotation

v2.0.0(4y ago)917[3 issues](https://github.com/navarr/dependency-annotation/issues)[2 PRs](https://github.com/navarr/dependency-annotation/pulls)MITPHPPHP ^7.1|^8CI failing

Since Jul 5Pushed 2y ago1 watchersCompare

[ Source](https://github.com/navarr/dependency-annotation)[ Packagist](https://packagist.org/packages/navarr/dependency-annotation)[ GitHub Sponsors](https://github.com/navarr)[ RSS](/packages/navarr-dependency-annotation/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (10)Dependencies (13)Versions (14)Used By (0)

The #\[Dependency\] Attribute
=============================

[](#the-dependency-attribute)

[![Latest Stable Version](https://camo.githubusercontent.com/041646ca40e0f1f6d2f6b1c2c69b98c9e2f73ca6ac03da4bc9834126dbc92d5e/687474703a2f2f706f7365722e707567782e6f72672f6e61766172722f646570656e64656e63792d616e6e6f746174696f6e2f76)](https://packagist.org/packages/navarr/dependency-annotation)[![Total Downloads](https://camo.githubusercontent.com/5189675891c333ee04efaeb4f0ba2cc6b1b1f2e59b467e08ee2fe1a9dfa43901/687474703a2f2f706f7365722e707567782e6f72672f6e61766172722f646570656e64656e63792d616e6e6f746174696f6e2f646f776e6c6f616473)](https://packagist.org/packages/navarr/dependency-annotation)[![Latest Unstable Version](https://camo.githubusercontent.com/ac649deeb978604f124e4fba49eba4ea64e0a9ff92660b6c21edc839c0661611/687474703a2f2f706f7365722e707567782e6f72672f6e61766172722f646570656e64656e63792d616e6e6f746174696f6e2f762f756e737461626c65)](https://packagist.org/packages/navarr/dependency-annotation)[![License](https://camo.githubusercontent.com/e3703229d3f0660a45f80e9be7931a9e6fc09ea8c1e82049880c78323698feea/687474703a2f2f706f7365722e707567782e6f72672f6e61766172722f646570656e64656e63792d616e6e6f746174696f6e2f6c6963656e7365)](https://packagist.org/packages/navarr/dependency-annotation)
[![Tests](https://github.com/navarr/dependency-annotation/actions/workflows/commit.yml/badge.svg)](https://github.com/navarr/dependency-annotation/actions/workflows/commit.yml/badge.svg)[![Code Coverage](https://camo.githubusercontent.com/5a632705c8918f451dbd54037afdc42ec7bdfcdefb5a54a0bfc2d94e9a8a61e8/68747470733a2f2f636f6465636f762e696f2f67682f6e61766172722f646570656e64656e63792d616e6e6f746174696f6e2f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d4248544b4f5a5a445233)](https://camo.githubusercontent.com/5a632705c8918f451dbd54037afdc42ec7bdfcdefb5a54a0bfc2d94e9a8a61e8/68747470733a2f2f636f6465636f762e696f2f67682f6e61766172722f646570656e64656e63792d616e6e6f746174696f6e2f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d4248544b4f5a5a445233)[![Mutation score](https://camo.githubusercontent.com/d4f636cb14869a6273ef215fcd4f718b13613596a4904c287cd348e8977ac692/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d2532466e6176617272253246646570656e64656e63792d616e6e6f746174696f6e2532466d61696e)](https://dashboard.stryker-mutator.io/reports/github.com/navarr/dependency-annotation/main)

This project supplies a Composer plugin that adds a command (`why-block`) that interprets a PHP `#[Dependency]`attribute.

How to use the `#[Dependency]` annotation
-----------------------------------------

[](#how-to-use-the-dependency-annotation)

Simply include a `#[Dependency]` attribute on any attributable target in the following format:

```
#[Navarr\Attribute\Dependency('package', 'versionConstraint', 'reason')]

```

This FQN may be imported, in which case you can simply use `#[Dependency(...)]`

All fields except the explanation are mandatory. Adding an explanation is *highly recommended*, however.

How to process reasons not to upgrade a composer dependency
-----------------------------------------------------------

[](#how-to-process-reasons-not-to-upgrade-a-composer-dependency)

If you are using the `#[Dependency]` annotation thoroughly, and you are having issues updating a composer dependency, you can use the command `composer why-block composer-package version`

This will output a list of files containing a `#[Dependency]` annotation on composer-package with a version-constraint that cannot be fulfilled by the specified version.

How to install
--------------

[](#how-to-install)

`composer global require navarr/dependency-annotation`

Compatibility with v1
---------------------

[](#compatibility-with-v1)

For speed, version 2 automatically excludes the legacy `@dependency` annotation in favor of the PHP8 `#[Dependency]`attribute. While transitioning, you may specify the `-l` or `--include-legacy-annotations` flag to the `why-block`command to force it to process v1 annotations as well.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~37 days

Recently: every ~3 days

Total

11

Last Release

1766d ago

Major Versions

v1.0.1 → v2.0.0-beta.12021-06-22

PHP version history (3 changes)v1.0.0PHP ^7.2

v2.0.0-beta.1PHP ^7.1

v2.0.0-beta.2PHP ^7.1|^8

### Community

Maintainers

![](https://www.gravatar.com/avatar/24959115e049fb1d71612462e9106b345b3e0e6126439493514018cd440e8937?d=identicon)[navarr](/maintainers/navarr)

---

Top Contributors

[![navarr](https://avatars.githubusercontent.com/u/145128?v=4)](https://github.com/navarr "navarr (63 commits)")

---

Tags

annotationscomposercomposer-plugindependency-parserhacktoberfestphp

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/navarr-dependency-annotation/health.svg)

```
[![Health](https://phpackages.com/badges/navarr-dependency-annotation/health.svg)](https://phpackages.com/packages/navarr-dependency-annotation)
```

###  Alternatives

[roave/backward-compatibility-check

Tool to compare two revisions of a public API to check for BC breaks

5953.3M56](/packages/roave-backward-compatibility-check)[coenjacobs/mozart

Composes all dependencies as a package inside a WordPress plugin

4723.6M20](/packages/coenjacobs-mozart)[vaimo/composer-patches

Applies a patch from a local or remote file to any package that is part of a given composer project. Patches can be defined both on project and on package level. Optional support for patch versioning, sequencing, custom patch applier configuration and patch command for testing/troubleshooting added patches.

2994.3M16](/packages/vaimo-composer-patches)[internal/dload

Downloads binaries.

98142.7k10](/packages/internal-dload)[php-forge/foxy

Fast, reliable, and secure Bun/NPM/Yarn/pnpm bridge for Composer

45103.3k4](/packages/php-forge-foxy)[drupal-code-builder/drupal-code-builder

Code generator for Drupal

27241.1k1](/packages/drupal-code-builder-drupal-code-builder)

PHPackages © 2026

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