RepoPHP is a PHP package that packs a repository into a single AI-friendly file for LLM processing. Similar to repomix
You can install the package via composer:
composer require vangelis/repophpYou can use the pack command to package a local repository directory into a single file, suitable for processing by AI-based systems.
-
repository (Required):
The path to the repository directory that you want to pack. -
output (Required):
The path to the output file where the packed content will be stored. -
--format <plain|markdown|json|xml> (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.
-
--exclude <pattern1,pattern2,...>:
Additional file patterns to exclude during the packing process.
These patterns are added to the default exclusions (e.g.,.env,composer.lock, etc.). -
--no-gitignore:
If this flag is provided,.gitignorefiles will not be used to exclude files.
Use the following command to pack a repository:
vendor/bin/repophp pack /path/to/repository /path/to/output --format=json --exclude="*.log,.env.local" --no-gitignore --compress - Packs the repository located at
/path/to/repository. - Stores the packed content in
/path/to/output. - Uses
jsonas the output format. - Excludes files matching the
*.logand.env.localpatterns. - Ignores
.gitignorerules. - Compresses the output file. Strip comments and empty lines.
-
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 inRepoPHP):plainmarkdownjsonxml
-
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 theRepoPHPclass.
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.
composer testPlease see CHANGELOG for more information on what has changed recently.
- 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
Please see CONTRIBUTING for details.
If you've found a bug regarding security please use the issue tracker.
The MIT License (MIT). Please see License File for more information.