PHPackages                             robertbyrnes/dir2db - 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. robertbyrnes/dir2db

ActiveLibrary

robertbyrnes/dir2db
===================

Uses PHP recursive iterator classes and regex iterator class to recursively search directories for .php files.

1.1.2(3y ago)118GPL-3.0-or-laterPHPPHP &gt;=8.1

Since Mar 28Pushed 3y ago1 watchersCompare

[ Source](https://github.com/RobertByrnes/dir2db)[ Packagist](https://packagist.org/packages/robertbyrnes/dir2db)[ RSS](/packages/robertbyrnes-dir2db/feed)WikiDiscussions master Synced 4d ago

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

dir2db
======

[](#dir2db)

[![](https://camo.githubusercontent.com/617bffb854e99bab1fa1a0cd8ce2b8004aa6f332ddab0c7632ebeba0841983d8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6d61646525323062792d526f626572744279726e65732d626c75652e737667)](https://camo.githubusercontent.com/617bffb854e99bab1fa1a0cd8ce2b8004aa6f332ddab0c7632ebeba0841983d8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6d61646525323062792d526f626572744279726e65732d626c75652e737667)[![](https://camo.githubusercontent.com/84d0399e09a7d96b8b516ede5415353db7650968d8881e0a7aec47bdc29e78f7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73746162696c6974792d7769702d7265642e737667)](https://camo.githubusercontent.com/84d0399e09a7d96b8b516ede5415353db7650968d8881e0a7aec47bdc29e78f7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73746162696c6974792d7769702d7265642e737667)[![](https://camo.githubusercontent.com/7d9ed3c8f22eceb1711573169b1390cc0b1194467340dc815205060c162b5309/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5052732d77656c636f6d652d627269676874677265656e2e7376673f7374796c653d666c6174)](https://camo.githubusercontent.com/7d9ed3c8f22eceb1711573169b1390cc0b1194467340dc815205060c162b5309/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5052732d77656c636f6d652d627269676874677265656e2e7376673f7374796c653d666c6174)

[![dir2db!](dir2db.jpg?raw=true "dir2db!")](dir2db.jpg?raw=true)

dir2db
======

[](#dir2db-1)

- Uses PHP recursive iterator classes and regex iterator class to recursively search directories for .php files.
- Any file extension may be searched for, or a group of them by passing in regex. See help description (run dir2db.php in cmd)
- Certain named directories may be excluded from the search, again by passing in regex through cmd (see help in dir2db.php)

Setup
-----

[](#setup)

Install via `git clone https://github.com/RobertByrnes/dir2db.git` then cd into package root directory and run `composer deploy-ini`

Use dir2db.sql to install `file_contents` table to a mySQL database.

For example run `mysql -u {$databaseUser} -p {$databaseName} < dir2db.sql`

Edit ./private/local.ini to include correct database credentials.

Useage
------

[](#useage)

In CMD/terminal type 'php dir2db.php', this will show the help menu:

```
    /*** ARGUMENTS ***/
    Required arguments:
        -p path, e.g. c:/wamp/www/
    Optional arguments:
        -r regex, to filter file search to only include certain file extension. Default: /\.(?:php)$/
        -e exclusions, directories ommited during search e.g. vendor|node_modules|private *Must include pipe*
        -h help, prints this help message.";

```

Examples
--------

[](#examples)

1. `php dir2db.php -p c:/wamp/www/repositories`
2. `php dir2db.php -p c:/wamp/www/repositories -r "/\.(?:txt)$/"`
3. `php dir2db.php -p c:/wamp/www/repositories -r "/\.(?:txt)$/" -e vendor|node_modules`
4. `php dir2db.php -p c:/wamp/www/repositories -r "/\.(?:txt|ini|sql)$/" -e vendor|node_modules`

- Example 1 will search all directories within repositories for php files
- Example 2 will search for .txt file within repositories
- Example 3 as example 2, additionally excluding anything within directories named 'vendor' or 'node\_modules'
- Example 4 demonstrates using the regex to include multiple file extensions

Memory Limit!
-------------

[](#memory-limit)

If you see a fatal exception - Allowed Memory Limit re-run your command explicity as shown below:

- `php .\dir2db.php -p c:/dir2db -r "/\.(?:jpg|png|pdf|php)$/" -e "vendor|node_modules"`
- `php -d memory_limit=-1 .\dir2db.php -p c:/dir2db -r "/\.(?:jpg|png|pdf|php)$/" -e "vendor|node_modules"`

The `-d memory_limit=-1` will tell php to ignore the memory limit whilst executing this process.

A note on Binary file types
---------------------------

[](#a-note-on-binary-file-types)

- The following binary file types are supported:
- 'pdf', 'jpg', 'jpeg', 'png', 'gif', 'svg', 'ico', 'bmp', 'tiff', 'tif', 'webp'
- file contents for these files will be stored in the `binary_file_content` database column which is of `LONGBLOB` type.
- Files not in this list are stored in the `file_content` column which is of `LONGTEXT` type.

FileFinder Trait
----------------

[](#filefinder-trait)

The FileFinder trait uses PHP's recursive iterator classes to search for files in a directory structure returning an array of results.

### Usage

[](#usage)

To use the FileFinder trait, call the `fileFinder` method with the following parameters:

- `$path` - The path to the directory you want to search
- `$fileFilter` (optional) - A regex to find PHP file extensions
- `$directoryFilter` (optional) - Directory names to exclude from the search

The `fileFinder` method will then return an array of results.

[![Files!](files.png?raw=true "Files!")](files.png?raw=true)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 60.9% 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

13

Last Release

1135d ago

PHP version history (3 changes)1.0.1PHP &gt;=7.4

1.0.9PHP &gt;=7.4|&gt;=8.1

1.1.2PHP &gt;=8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/59289145?v=4)[Robert Byrnes](/maintainers/RobertByrnes)[@RobertByrnes](https://github.com/RobertByrnes)

---

Top Contributors

[![RobertByrnes](https://avatars.githubusercontent.com/u/59289145?v=4)](https://github.com/RobertByrnes "RobertByrnes (28 commits)")[![RobertAByrnes](https://avatars.githubusercontent.com/u/90920797?v=4)](https://github.com/RobertAByrnes "RobertAByrnes (18 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/robertbyrnes-dir2db/health.svg)

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

PHPackages © 2026

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