这是indexloc提供的服务,不要输入任何密码
Skip to content

dimovdaniel/repophp

 
 

Repository files navigation

RepoPHP

Latest Version on Packagist
Tests
Total Downloads

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

Installation

You can install the package via composer:

composer require vangelis/repophp

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:

  • 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, .gitignore files will not be used to exclude files.

Example Usage

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  

Breakdown:

  • Packs the repository located at /path/to/repository.
  • Stores the packed content in /path/to/output.
  • Uses json as the output format.
  • Excludes files matching the *.log and .env.local patterns.
  • Ignores .gitignore rules.
  • Compresses the output file. Strip comments and empty lines.

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

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

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

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

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

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

Credits

License

The MIT License (MIT). Please see License File for more information.

About

RepoPHP packs a repository into a single AI-friendly file for LLM processing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%