PHPackages                             griffin/harpy - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. griffin/harpy

ActiveLibrary[File &amp; Storage](/categories/file-storage)

griffin/harpy
=============

Search for Classes Names inside PHP Source Code

1.0.2(5y ago)032MITPHP

Since May 8Pushed 5y ago1 watchersCompare

[ Source](https://github.com/griffin-php/harpy)[ Packagist](https://packagist.org/packages/griffin/harpy)[ RSS](/packages/griffin-harpy/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (1)Dependencies (8)Versions (4)Used By (0)

harpy
=====

[](#harpy)

Search for Classes Names inside PHP Source Code

[![Build Status](https://github.com/griffin-php/harpy/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/griffin-php/harpy/actions/workflows/test.yml?query=branch%3Amain)[![Latest Stable Version](https://camo.githubusercontent.com/bd68da341d08741c65c84053501a80a328f34982b61c1502070527dfe274c4d1/68747470733a2f2f706f7365722e707567782e6f72672f6772696666696e2f68617270792f762f737461626c653f666f726d61743d666c6174)](https://packagist.org/packages/griffin/harpy)[![Codecov](https://camo.githubusercontent.com/003c7a0b4a812e8edba10c8b82dc6979795dfd654cded624b6c5600f4faec352/68747470733a2f2f636f6465636f762e696f2f67682f6772696666696e2d7068702f68617270792f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://codecov.io/gh/griffin-php/harpy)[![License](https://camo.githubusercontent.com/4c180b81f2def0c44cf9cad3c6d0a26f4cde69c5795b1d4e07b9efb1114bea2f/68747470733a2f2f706f7365722e707567782e6f72672f6772696666696e2f68617270792f6c6963656e73653f666f726d61743d666c6174)](https://packagist.org/packages/griffin/harpy)

Description
-----------

[](#description)

Harpy is a micro library to search for classes names inside PHP source code, using patterns to find files and parsing them to retrieve all defined classes.

This library is part of [Griffin Project](https://github.com/griffin-php).

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

[](#installation)

This package uses [Composer](https://packagist.org/packages/griffin/harpy) as default repository. You can install it adding the name of package in `require`section of `composer.json`, pointing to the latest stable version.

```
{
  "require": {
    "griffin/harpy": "^1.0"
  }
}
```

Usage
-----

[](#usage)

The `Griffin\Harpy\Harpy::search` method use variadic parameters of `string`representing files or directories. These directories will be recursively listed searching for files. Each file found will be parsed searching for class definitions.

```
use Griffin\Harpy\Harpy;

$harpy = new Harpy();

$classnames = $harpy->search(
    // Files
    './src/Harpy.php',
    './tests/HarpyTest.php',
    // Directories
    './src',
    './tests',
);

var_dump($classnames);

/*
array(6) {
  [0]=>
  string(19) "Griffin\Harpy\Harpy"
  [1]=>
  string(27) "GriffinTest\Harpy\HarpyTest"
  [2]=>
  string(20) "Griffin\Harpy\Finder"
  [3]=>
  string(20) "Griffin\Harpy\Parser"
  [4]=>
  string(28) "GriffinTest\Harpy\FinderTest"
  [5]=>
  string(28) "GriffinTest\Harpy\ParserTest"
}
 */
```

If Harpy hasn't permissions to list directories or read files, warnings will not be raised, because it only searches for classes and not handles errors. Also, Harpy is not a class loader, you must use tools like Composer to execute this job.

Example
-------

[](#example)

An example is retrieve all classes from directory and initialize a object if class implements specific interface.

```
use FooBar\ExampleInterface;
use Griffin\Harpy\Harpy;

$objects    = [];
$classnames = (new Harpy())->search('src');

foreach ($classnames as $classname) {
    if (is_subclass_of($classname, ExampleInterface::class, true /* allow string */)) {
        $objects[] = new $classname();
    }
}
```

Development
-----------

[](#development)

You can use Docker Compose to build an image and run a container to develop and test this package.

```
docker-compose build
docker-compose run --rm php composer install
docker-compose run --rm php composer test
```

References
----------

[](#references)

- [nikic/PHP-Parser](https://github.com/nikic/PHP-Parser): A PHP parser written in PHP

License
-------

[](#license)

This package is opensource and available under MIT license described in [LICENSE](https://github.com/griffin-php/harpy/blob/main/LICENSE).

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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 ~1 days

Total

3

Last Release

1878d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/907c8faa9e7d6e1777b18bafcc2b94909b1b82a9fe15b462fb18b02f88a00da1?d=identicon)[wandersonwhcr](/maintainers/wandersonwhcr)

---

Top Contributors

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

---

Tags

classesclassnamesfindergriffinparserparserfinderclassesclassnamesgriffin

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/griffin-harpy/health.svg)

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

###  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)[ergebnis/classy

Provides collectors for classy constructs (classes, enums, interfaces, and traits).

393.0M25](/packages/ergebnis-classy)[yosymfony/resource-watcher

A simple resource watcher using Symfony Finder

698.8M22](/packages/yosymfony-resource-watcher)[arthurhoaro/favicon

PHP Library used to discover favicon from given URL

32776.7k](/packages/arthurhoaro-favicon)[ahmed-bhs/doctrine-doctor

Runtime analysis tool for Doctrine ORM integrated into Symfony Web Profiler. Unlike static linters, it analyzes actual query execution at runtime to detect performance bottlenecks, security vulnerabilities, and best practice violations during development with real execution context and data.

9410.7k](/packages/ahmed-bhs-doctrine-doctor)

PHPackages © 2026

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