PHPackages                             jerowork/class-dependencies-parser - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. jerowork/class-dependencies-parser

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

jerowork/class-dependencies-parser
==================================

Parse all dependencies (FQN) used in an object (e.g. class, trait, interface)

0.5.1(3y ago)22711[1 PRs](https://github.com/jerowork/class-dependencies-parser/pulls)MITPHPPHP ^8.1

Since Dec 21Pushed 3y ago1 watchersCompare

[ Source](https://github.com/jerowork/class-dependencies-parser)[ Packagist](https://packagist.org/packages/jerowork/class-dependencies-parser)[ RSS](/packages/jerowork-class-dependencies-parser/feed)WikiDiscussions main Synced today

READMEChangelog (9)Dependencies (7)Versions (11)Used By (0)

class-dependencies-parser
=========================

[](#class-dependencies-parser)

[![Build Status](https://camo.githubusercontent.com/cff86f682cf1485e09a827225c82b06a7b118c8a4bb0dd666be2190a9aa40348/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e742e7376673f75726c3d6874747073253341253246253246616374696f6e732d62616467652e6174726f782e6465762532466a65726f776f726b253246636c6173732d646570656e64656e636965732d70617273657225324662616467652533467265662533446d61696e267374796c653d666c61742d737175617265)](https://github.com/jerowork/class-dependencies-parser/actions)[![Coverage Status](https://camo.githubusercontent.com/48ffbc0c8950c34c562c6ebc0544b1336773d38f6604d8bc5d7b4e24a0a367d3/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6a65726f776f726b2f636c6173732d646570656e64656e636965732d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/jerowork/class-dependencies-parser/code-structure)[![Quality Score](https://camo.githubusercontent.com/e7c8c246b6633eac0f761a9b67948003bb9fe42c2f1ed8d31b228da2d722b05f/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6a65726f776f726b2f636c6173732d646570656e64656e636965732d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/jerowork/class-dependencies-parser)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Packagist Version](https://camo.githubusercontent.com/24528b3d3859f46f69478a77bb16a072dad1c07cfeb69151d7824457423d88d7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a65726f776f726b2f636c6173732d646570656e64656e636965732d7061727365722e7376673f7374796c653d666c61742d73717561726526696e636c7564655f70726572656c6561736573)](https://packagist.org/packages/jerowork/class-dependencies-parser)[![PHP Version](https://camo.githubusercontent.com/6f61c16385e121f1009c477296e9a88d9352813581b8b66a97fed5237b222457/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d3838393242462e7376673f7374796c653d666c61742d737175617265)](http://www.php.net)

Parse all dependencies (FQN) used in a class (e.g. class, trait, interface, enum).

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

[](#installation)

Install via [Composer](https://getcomposer.org/):

```
composer require jerowork/class-dependencies-parser
```

Usage
-----

[](#usage)

```
use Jerowork\ClassDependenciesParser\PhpParser\NodeTraverserFactory;
use Jerowork\ClassDependenciesParser\PhpParser\PhpParserClassDependenciesParser;
use PhpParser\ParserFactory;

// Setup parser
$parser = new PhpParserClassDependenciesParser(
    (new ParserFactory())->create(ParserFactory::PREFER_PHP7),
    new NodeTraverserFactory(),
);

// Parse file
$classDependencies = $parser->parse('/Path/To/file.php');

// Output dependencies
print_r(
    $classDependencies->getDependencyList(),
);

// This will output e.g.:
[
    'Some/Namespace/Class',
    'Another/Namespace/Trait',
    // ...
]
```

DI service definition
---------------------

[](#di-service-definition)

As a good practice we should always 'program to interfaces, not implementations', you should add this to your DI container.

PSR-11 Container example:

```
use Jerowork\ClassDependenciesParser\ClassDependenciesParser;
use Jerowork\ClassDependenciesParser\PhpParser\NodeTraverserFactory;
use Jerowork\ClassDependenciesParser\PhpParser\PhpParserClassDependenciesParser;
use PhpParser\ParserFactory;

return [
    ClassDependenciesParser::class => static function (ContainerInterface $container): ClassDependenciesParser {
        return new PhpParserClassDependenciesParser(
            (new ParserFactory())->create(ParserFactory::PREFER_PHP7),
            new NodeTraverserFactory(),
        );
    },
];
```

Symfony YAML-file example:

```
services:
  _defaults:
    autowire: true
    autoconfigure: true

  Jerowork\ClassDependenciesParser\ClassDependenciesParser:
    class: Jerowork\ClassDependenciesParser\PhpParser\PhpParserClassDependenciesParser

  Jerowork\ClassDependenciesParser\PhpParser\NodeTraverserFactory: ~

  PhpParser\ParserFactory: ~

  PhpParser\Parser:
    factory: ['@PhpParser\ParserFactory', 'create']
    arguments:
      $kind: 1
```

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57.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 ~8 days

Recently: every ~1 days

Total

9

Last Release

1225d ago

PHP version history (2 changes)0.1.0PHP ^8.2

0.3.0PHP ^8.1

### Community

Maintainers

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

---

Top Contributors

[![jerowork](https://avatars.githubusercontent.com/u/4119451?v=4)](https://github.com/jerowork "jerowork (23 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (17 commits)")

---

Tags

dependenciesfcqnfqnparserreflectionparserreflectiondependenciesfqcnfqn

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/jerowork-class-dependencies-parser/health.svg)

```
[![Health](https://phpackages.com/badges/jerowork-class-dependencies-parser/health.svg)](https://phpackages.com/packages/jerowork-class-dependencies-parser)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[psx/schema

Parse and generate data schema formats

57245.5k24](/packages/psx-schema)[corveda/php-sandbox

A PHP library that can be used to run PHP code in a sandboxed environment

23796.2k2](/packages/corveda-php-sandbox)[composer-unused/symbol-parser

Toolkit to parse symbols from a composer package

156.6M2](/packages/composer-unused-symbol-parser)[atanamo/php-codeshift

A PHP code transformation toolkit based on 'PHP-Parser'

32160.3k1](/packages/atanamo-php-codeshift)

PHPackages © 2026

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