PHPackages                             morebec/file-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. morebec/file-locator

ActiveLibrary

morebec/file-locator
====================

The FileLocator Component find files by their name using different strategies, such as recursive parent traversal, recursive (downward) traversal and at location

2.0(6y ago)05MITPHPCI failing

Since Dec 7Pushed 6y ago1 watchersCompare

[ Source](https://github.com/Morebec/FileLocator)[ Packagist](https://packagist.org/packages/morebec/file-locator)[ RSS](/packages/morebec-file-locator/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (4)Used By (0)

FileLocator
===========

[](#filelocator)

[![Build Status](https://camo.githubusercontent.com/fe20d5a085159a015cc758aebb68b9f642068b799ca5f10d1b6d3aa0c5912b5a/68747470733a2f2f7472617669732d63692e636f6d2f4d6f72656265632f46696c654c6f6361746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/Morebec/FileLocator)

The FileLocator Component allows one to locate files using different strategies. This is mostly useful to find configuration files or project roots, e.g. trying to find a possibly near `composer.json` file.

There are three strategies:

- Recursive up: Tries to find a file at specified location, and if not found goes one level up and repeats this process until the file is found, or until there is no longer a parent level.
- Recursive down: Tries to find a file in the at specified location, and if not found goes one level down
- At location: Tries to find a file only at the specified location without going up or down

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

[](#installation)

To install the library in a project, add these lines to your `composer.json` configuration file:

```
{
    "repositories": [
        {
            "url": "https://github.com/Morebec/FileLocator.git",
            "type": "git"
        }
    ],
    "require": {
        "morebec/file-locator": "^1.0"
    }
}

```

Usage
-----

[](#usage)

The `FileLocator` has a single entry point where one needs to provide, the name of the file to find, the location and the strategy.

Here is an example to find composer in the parent directories of the current working directory:

```
$locator = new FileLocator();
$file = $locator->find(
    'composer.json',
    Directory::fromStringPath(getcwd()),
    FileLocatorStrategy::RECURSIVE_UP()
);

if(!$file) {
    throw new \Exception('Composer could not be found.');
}

// Parse composer file
$composerConfig = json_decode($file->getContents(), true);
```

Running Tests
-------------

[](#running-tests)

```
composer test
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

Total

2

Last Release

2344d ago

Major Versions

1.0 → 2.02019-12-10

### Community

Maintainers

![](https://www.gravatar.com/avatar/10d7f5561446f2d4df4413803946e9f77175155d241f78bd65c0dd94e6caffc5?d=identicon)[jwillp](/maintainers/jwillp)

---

Top Contributors

[![jwillp](https://avatars.githubusercontent.com/u/5913483?v=4)](https://github.com/jwillp "jwillp (9 commits)")

---

Tags

filefilelocatorfilelocator-componentphptraversal

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/morebec-file-locator/health.svg)

```
[![Health](https://phpackages.com/badges/morebec-file-locator/health.svg)](https://phpackages.com/packages/morebec-file-locator)
```

###  Alternatives

[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k235.4M9.7k](/packages/symfony-framework-bundle)[laravel/pennant

A simple, lightweight library for managing feature flags.

57311.1M53](/packages/laravel-pennant)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19462.3M1.3k](/packages/drupal-core)[symplify/monorepo-builder

Not only Composer tools to build a Monorepo.

5205.3M82](/packages/symplify-monorepo-builder)[coenjacobs/mozart

Composes all dependencies as a package inside a WordPress plugin

4723.6M20](/packages/coenjacobs-mozart)[horstoeko/zugferd

A library for creating and reading european electronic invoices

4044.3M18](/packages/horstoeko-zugferd)

PHPackages © 2026

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