PHPackages                             rkr/php-structure-locator - 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. rkr/php-structure-locator

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

rkr/php-structure-locator
=========================

A PHP library to locate classes, functions, and other stuff in PHP files using xml and xpath.

1.0.1(2mo ago)0378MITPHPPHP &gt;= 8.1

Since Feb 8Pushed 2mo agoCompare

[ Source](https://github.com/rkrx/php-structure-locator)[ Packagist](https://packagist.org/packages/rkr/php-structure-locator)[ Docs](https://github.com/rkrx/php-structure-locator)[ RSS](/packages/rkr-php-structure-locator/feed)WikiDiscussions main Synced 1mo ago

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

PHP Code Indexer
================

[](#php-code-indexer)

A tool for indexing PHP code elements including functions, classes, methods, properties, parameters, PHPDoc annotations, attributes and their relative file paths to enable efficient searching using `xpath`.

Overview
--------

[](#overview)

The indexer performs the following steps:

1. Uses symfony/finder to locate PHP files
2. Detects which files have changed, been added or removed
3. Indexes the code elements in an XML data structure
4. Stores the index in an easily searchable XML file
5. Enables searching via XPath queries

Command line Usage
------------------

[](#command-line-usage)

```
php index.php --out index.xml --include 'src/{*,**/*}.php' --include 'tests/{*,**/*}.php'
```

### Explanation

[](#explanation)

ParameterShortRequiredDescription`--out ``-o `YesPath to the output XML file for storing the index`--include ``-i `YesDirectory to include for indexing; can be used multiple times`--exclude ``-e `NoGlob pattern to exclude files or folders from the included directories`--working-directory ``-w `NoSets the base directory for all relative pathsNotes:

- At least one `--include` is required.
- `--exclude` applies only within the scope of the specified `--include` paths.
- Patterns for `--exclude` support common glob syntax:
    - `*` matches any string.
    - `xyz/*.*` matches any file with an extension.
    - `**/XyzTest.php` matches directories recursively.
    - `XyzTest.{php,inc}` matches multiple file extensions.
    - `src/{*,**/*}.php` matches all `.php` files in the `src` directory and its subdirectories.
- If --working-directory is not set, the current working directory is used.

Usage Example
-------------

[](#usage-example)

Find all attributes of class-methods with a specific name: `//class/method/attribute[@name='NS\\MyAttribute']`

First, index your PHP files:

```
use PhpLocate\UpdateIndexService;
use Psr\Log\NullLogger;
use Symfony\Component\Finder\Finder;

$files = (new Finder())
    ->in(__DIR__ . '/src')
    ->name('*.php');

$service = new UpdateIndexService(new NullLogger());
$service->updateIndex(indexPath: __DIR__ . '/index.xml', files: $files);
```

Then, search the index using XPath:

```
use PhpLocate\Index;

$index = Index::fromFile(__DIR__ . '/index.xml');
$path = $index->getFirstString("/files/file[class/method/attribute[@name='NS\\MyAttribute']]/@path");
echo $path;
```

Progress
========

[](#progress)

- Functions
    - Attributes
        - Arguments
    - Parameters
        - Attributes
            - Arguments
        - Type hint
    - Return type
    - PHPDoc annotations
    - Class definitions
        - Attributes
            - Arguments
        - PHPDoc annotations
        - Final mark
        - Abstract mark
        - Implementing Interfaces
        - Extending class
        - Methods
            - Attributes
                - Arguments
            - Visibility
            - Static mark
            - Final mark
            - Abstract mark
            - Constructor methods
            - Parameters
                - Attributes
                    - Arguments
                - Type hint
            - Return type
        - Traits (merging methods and properties into classes)
            - Attributes
                - Arguments
            - Constants ...
                - Attributes
                    - Arguments
            - Properties ...
                - Attributes
                    - Arguments
            - Methods ...
                - Attributes
                    - Arguments

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance85

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

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

Total

2

Last Release

75d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7f83d7e57a4bf3f1309680dbfbbf2d022f0ee6dae64a4b3bdfbed1226f2f6bef?d=identicon)[rkr](/maintainers/rkr)

---

Top Contributors

[![rkrx](https://avatars.githubusercontent.com/u/5672982?v=4)](https://github.com/rkrx "rkrx (48 commits)")

---

Tags

phpxmlparserfinderstructurelocatorXpath

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rkr-php-structure-locator/health.svg)

```
[![Health](https://phpackages.com/badges/rkr-php-structure-locator/health.svg)](https://phpackages.com/packages/rkr-php-structure-locator)
```

###  Alternatives

[danog/madelineproto

Async PHP client API for the telegram MTProto protocol.

3.4k855.0k18](/packages/danog-madelineproto)[goetas-webservices/xsd-reader

Read any XML Schema (XSD) programmatically with PHP

624.7M15](/packages/goetas-webservices-xsd-reader)

PHPackages © 2026

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