PHPackages                             popphp/pop-dir - 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. popphp/pop-dir

ActiveLibrary

popphp/pop-dir
==============

Pop Directory Component for Pop PHP Framework

4.0.3(6mo ago)26.4k↓50%4BSD-3-ClausePHPPHP &gt;=8.3.0CI passing

Since Feb 22Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/popphp/pop-dir)[ Packagist](https://packagist.org/packages/popphp/pop-dir)[ Docs](https://github.com/popphp/pop-dir)[ RSS](/packages/popphp-pop-dir/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (15)Used By (4)

pop-dir
=======

[](#pop-dir)

[![Build Status](https://github.com/popphp/pop-dir/workflows/phpunit/badge.svg)](https://github.com/popphp/pop-dir/actions)[![Coverage Status](https://camo.githubusercontent.com/168c9def91b90e70ab228da57fb15e6724bc806cb8d5ed9bcb321274af810624/687474703a2f2f63632e706f707068702e6f72672f636f7665726167652e7068703f636f6d703d706f702d646972)](http://cc.popphp.org/pop-dir/)

[![Join the chat at https://discord.gg/TZjgT74U7E](https://camo.githubusercontent.com/acad7b0eeb78b78d08ffd2b85681ab243436388b5f86f8bcb956a69246e53739/68747470733a2f2f6d656469612e706f707068702e6f72672f696d672f646973636f72642e737667)](https://discord.gg/TZjgT74U7E)

- [Overview](#overview)
- [Install](#install)
- [Quickstart](#quickstart)
- [Options](#options)
- [Empty](#empty)

Overview
--------

[](#overview)

`pop-dir` is a component for easily traversing files and subdirectories within a directory.

It is a component of the [Pop PHP Framework](https://www.popphp.org/).

[Top](#pop-dir)

Install
-------

[](#install)

Install `pop-dir` using Composer.

```
composer require popphp/pop-dir

```

Or, require it in your composer.json file

```
"require": {
    "popphp/pop-dir" : "^4.0.3"
}

```

[Top](#pop-dir)

Quickstart
----------

[](#quickstart)

##### Traversing a directory

[](#traversing-a-directory)

```
use Pop\Dir\Dir;

$dir = new Dir('my-dir');

foreach ($dir->getFiles() as $file) {
    echo $file;
}
```

If you want to traverse the directory recursively and get the full path of each file.

```
use Pop\Dir\Dir;

$dir = new Dir('my-dir', [
    'absolute'  => true,
    'recursive' => true
]);

foreach ($dir->getFiles() as $file) {
    echo $file;
}
```

[Top](#pop-dir)

Options
-------

[](#options)

The available boolean options for the `$options` array parameter are:

```
$options = [
    'absolute'  => true,  // store the absolute, full path of the items in the directory
    'relative'  => false  // store the relative path of the items in the directory
    'recursive' => true,  // traverse the directory recursively
    'filesOnly' => false, // store only files in the object (and not other directories)
];
```

The `absolute` and `relative` options cannot be used together.

If `absolute` is set to `true`, it will return the absolute path of the files and directories:

```
'/home/path/file1.txt`
'/home/path/file2.txt`

```

If `relative` is set to `true`, it will return the relative path of the files and directories:

```
'path/file1.txt`
'path/file2.txt`

```

If neither are passed, it will return only the base file names and directory names:

```
'file1.txt`
'file2.txt`

```

[Top](#pop-dir)

Empty
-----

[](#empty)

The directory can be emptied with the `emptyDir()` method:

```
use Pop\Dir\Dir;

$dir = new Dir('my-dir');
$dir->emptyDir();
```

The `true` flag will remove the actual directory as well (use with caution):

```
$dir->emptyDir(true);
```

[Top](#pop-dir)

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance66

Regular maintenance activity

Popularity25

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity86

Battle-tested with a long release history

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

Recently: every ~269 days

Total

10

Last Release

200d ago

Major Versions

3.2.1 → 4.0.02023-11-09

PHP version history (7 changes)3.0.0PHP &gt;=5.6.0

3.0.2PHP &gt;=7.1.0

3.2.0PHP &gt;=7.3.0

3.2.1PHP &gt;=7.4.0

4.0.0PHP &gt;=8.1.0

4.0.1PHP &gt;=8.2.0

4.0.3PHP &gt;=8.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/c19dee900e9e20039c723cc403f76b5c22ac2dddb3f86773ae64fb082d4949e2?d=identicon)[nicksagona](/maintainers/nicksagona)

---

Top Contributors

[![nicksagona](https://avatars.githubusercontent.com/u/898670?v=4)](https://github.com/nicksagona "nicksagona (31 commits)")

---

Tags

phpdirectorypoppop phpdirectory traversing

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/popphp-pop-dir/health.svg)

```
[![Health](https://phpackages.com/badges/popphp-pop-dir/health.svg)](https://phpackages.com/packages/popphp-pop-dir)
```

###  Alternatives

[popphp/pop-db

Pop Db Component for Pop PHP Framework

1814.6k11](/packages/popphp-pop-db)[popphp/pop-pdf

PHP PDF library for generating and importing PDF documents. A component of the Pop PHP Framework

207.8k1](/packages/popphp-pop-pdf)[popphp/pop-http

Pop Http Component for Pop PHP Framework

1018.5k13](/packages/popphp-pop-http)

PHPackages © 2026

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