PHPackages                             vangelis/repophp - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. vangelis/repophp

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

vangelis/repophp
================

RepoPHP is a PHP package that packs a repository into a single AI-friendly file for LLM processing.

0.7.2(1y ago)572[3 PRs](https://github.com/vangelis183/repophp/pulls)MITPHPPHP ^8.3CI passing

Since Feb 23Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/vangelis183/repophp)[ Packagist](https://packagist.org/packages/vangelis/repophp)[ Docs](https://github.com/vangelis183/repophp)[ GitHub Sponsors](https://github.com/vangelis183)[ RSS](/packages/vangelis-repophp/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (7)Versions (14)Used By (0)

RepoPHP
=======

[](#repophp)

[![Latest Version on Packagist](https://camo.githubusercontent.com/9a98e3f1a31ac7f177a621a1472d9ff09d8b8d29149b9795910e71fdd9606504/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f76616e67656c69732f7265706f7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vangelis/repophp) [![Tests](https://camo.githubusercontent.com/a72860d5e58595727b377afbc1611f6099039f4a760677a268d29adb1215d89e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f76616e67656c69733138332f7265706f7068702f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/vangelis183/repophp/actions/workflows/run-tests.yml) [![Total Downloads](https://camo.githubusercontent.com/412f6cbb9717df4ae333dd0faa90855f345855c335f8cfaadfaf494f9e8386d5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f76616e67656c69732f7265706f7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vangelis/repophp)

RepoPHP is a PHP package that packs a repository into a single AI-friendly file for LLM processing. Similar to \[repomix\]() Demo
----

[](#demo)

[![RepoPHP Demo](demo/repophp-demo.gif)](demo/repophp-demo.gif)

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

[](#installation)

You can install the package via composer:

```
composer require vangelis/repophp --dev
```

Configuration File
------------------

[](#configuration-file)

RepoPHP supports a configuration file to set default options. Create one of these files in your project directory:

- `.repophp.json`
- `repophp.json`
- `.repophp.config.json`
- `repophp.config.json`

Example configuration file:

```
{
  "repository": "/path/to/repository",
  "output": "packed_repo.txt",
  "format": "markdown",
  "encoding": "cl100k_base",
  "exclude": [".env.local", "*.log"],
  "no-gitignore": false,
  "compress": true,
  "max-tokens": 100000,
  "remote": false,
  "branch": "main",
  "incremental": false,
  "base-file": null
}
```

With this configuration file in place, you can simply run:

```
vendor/bin/repophp pack
```

Command-line arguments will override settings from the configuration file.

Usage
-----

[](#usage)

Pack Command Usage
------------------

[](#pack-command-usage)

You can use the `pack` command to package a local repository directory into a single file, suitable for processing by AI-based systems.

### Available Options for the pack Command:

[](#available-options-for-the-pack-command)

#### Required Arguments:

[](#required-arguments)

- **output**: The path to the `output` file where the packed content will be stored.
- **repository**: The path to the `repository` directory that you want to pack or a remote repository URL if used with the --remote flag.

#### Optional Flags and Settings:

[](#optional-flags-and-settings)

- **--remote, -rem:**Treat the repository argument as a remote Git repository URL.
- **--branch , -bra (default: main):**Branch to checkout when cloning a remote repository.
- **--format &lt;plain|markdown|json|xml&gt;, -fmt (default: plain):**Specifies the format of the output file. Supported formats:

    - `plain`: Plain text format.
    - `markdown`: Markdown format for better readability.
    - `json`: JSON format for structured data.
    - `xml`: XML format for structured data.
- **--encoding , -enc (default: p50k\_base):**Token encoding to use (cl100k\_base, p50k\_base, r50k\_base, p50k\_edit).
- **--exclude , -exc :**Additional file patterns to exclude during the packing process. These patterns are added to the default exclusions (e.g., .env, composer.lock, etc.). This option can be used multiple times to add multiple patterns.
- **--max-tokens , -max (default: 0):**Maximum number of tokens per output file. If set to a positive number, the repository will be split into multiple files when the token limit is reached. Set to 0 (default) for no limit.
- **--no-gitignore, -nog:**If this flag is provided, .gitignore files will not be used to exclude files.
- **--compress, -com:**Remove comments and empty lines from files for more compact output.

### Example Usage

[](#example-usage)

**Local repository:**

```
vendor/bin/repophp pack output.txt /path/to/repository --format=json --exclude="*.log" --exclude=".env.local" --no-gitignore --compress
```

**Remote Repository:**

```
vendor/bin/repophp pack output.txt https://github.com/username/repository.git --remote --branch develop
```

**With short option names:**

```
vendor/bin/repophp pack output.txt /path/to/repo -fmt json -com -enc cl100k_base
```

**Complex example:**

```
vendor/bin/repophp pack output.txt https://github.com/vangelis183/repophp.git --remote --branch main --compress --encoding cl100k_base --format plain
```

**Split large repository by token count:**

```
vendor/bin/repophp pack output.txt /path/to/repo --max-tokens=100000 --encoding cl100k_base
```

**Incremental packing (diff mode):**

```
vendor/bin/repophp pack output.txt /path/to/repo --incremental --base-file=/path/to/previous/pack.txt
```

This will create a diff file containing only files that have changed since the previous pack, which is especially useful for large repositories where you only want to analyze recent changes.

#### Breakdown:

[](#breakdown)

- Packs the repository located at `/path/to/repository` or clones the remote repository URL.
- Stores the packed content in `/path/to/output.txt`.
- Uses the specified output format (json, plain, markdown, or xml).
- Excludes files matching the specified patterns.
- Option to ignore `.gitignore` rules.
- Option to compress the output by removing comments and empty lines.
- For remote repositories, checks out the specified branch.
- Uses the specified token encoding for calculating token counts.

### Additional Behavior

[](#additional-behavior)

- **Overwrite Handling**:
    If the output file already exists, you will be prompted to confirm whether you want to overwrite the file. If you choose not to overwrite, a new file will be created with a timestamp appended to its name.
- **Supported Formats**:
    The following formats are supported (as defined in `RepoPHP`):

    - `plain`
    - `markdown`
    - `json`
    - `xml`
- **Default Exclusions**:
    Some files are excluded automatically during the packing process (e.g., `.env`, `composer.lock`, and other commonly ignored files). The list of default exclusions can be found in the `RepoPHP` class.

### Error Handling

[](#error-handling)

The `pack` command gracefully handles errors such as:

- Invalid repository paths.
- Invalid output paths.
- Unsupported output formats.
- Failures in creating or writing the output file.

If any error occurs, an appropriate error message will be shown in the console.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

ToDos
-----

[](#todos)

- Move settings to configuration
- Git Repositiory Information
- Directory structure
- More tests
- Token Count for each file and entire repo
- Consider different encodings
- Add compression (Comments etc.)
- Add option for remote Git Repositories
- Add option for specific branch
- Add repository splitting for large codebases
- Implement incremental/diff-based packing
- Add editable custom config to override defaults
- Add security checks for files (Keys, Passwords etc.)
- Create advanced filtering options (by date, content)
- Add repository analytics and metrics
- Implement model-specific optimization profiles
- Develop CI/CD integration options
- Build interactive CLI mode

Ideas
-----

[](#ideas)

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

If you've found a bug regarding security please use the issue tracker.

Credits
-------

[](#credits)

- [Evangelos Dimitriadis](https://github.com/vangelis183)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance76

Regular maintenance activity

Popularity10

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

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

8

Last Release

431d ago

### Community

Maintainers

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

---

Top Contributors

[![vangelis183](https://avatars.githubusercontent.com/u/102213?v=4)](https://github.com/vangelis183 "vangelis183 (68 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")

---

Tags

aianthropicanthropic-claudechatbotclaudedeveloper-toolsgenerative-ailanguage-modelllmopenaiphprepositoryrepophp

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/vangelis-repophp/health.svg)

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

###  Alternatives

[symfony/maker-bundle

Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.

3.4k111.1M564](/packages/symfony-maker-bundle)[wnx/laravel-stats

Get insights about your Laravel Project

1.8k1.8M7](/packages/wnx-laravel-stats)[symplify/monorepo-builder

Not only Composer tools to build a Monorepo.

5205.3M81](/packages/symplify-monorepo-builder)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k17](/packages/civicrm-civicrm-core)[shyim/danger-php

Port of danger to PHP

8544.9k](/packages/shyim-danger-php)[phuml/phuml

phUML is a fully automatic UML class diagram generator for PHP code

11411.3k1](/packages/phuml-phuml)

PHPackages © 2026

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