PHPackages                             codebase-dump/php - 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. codebase-dump/php

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

codebase-dump/php
=================

Generate a single-file dump of your repository for LLM input

v1.0.0(3mo ago)00MITPHPPHP ^8.4

Since Feb 11Pushed 3mo agoCompare

[ Source](https://github.com/robertgdev/llm-php-codedump)[ Packagist](https://packagist.org/packages/codebase-dump/php)[ RSS](/packages/codebase-dump-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Codebase Dump (PHP)
===================

[](#codebase-dump-php)

An AI-assisted PHP 8.4 port of the Python [codebase-dump](https://github.com/frogermcs/codebase-dump) tool. It generates a single-file dump of your repository for LLM input.

Rationale
---------

[](#rationale)

I was frustrated that I didn't find a native PHP tool for this task. The tools I did find, were written in Python, NodeJS and Rust and all of them came with environment/dependency issues I didn't want to deal with. With the help of some AI coding tools, I generated this port. It hasn't been tested extensively, but I've used it on a few projects and it seemed to work fine.

Description
-----------

[](#description)

This tool analyzes a codebase directory and generates a structured text or markdown representation that can be used as input for Large Language Models (LLMs). It:

- Recursively analyzes directory structures
- Identifies and ignores common non-source files (compiled code, dependencies, etc.)
- Reads text file contents
- Generates tree representations
- Calculates file sizes and estimates token counts
- Supports custom ignore patterns (via `.gitignore` and `.cdigestignore`)
- Optionally uploads results to the [Code Audits API](https://codeaudits.ai/)

Requirements
------------

[](#requirements)

- PHP 8.4 or higher
- Composer for dependency management

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

[](#installation)

```
# Install dependencies
cd php
composer install
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
php src/cli.php /path/to/your/project
```

### Command Line Options

[](#command-line-options)

```
php src/cli.php  [options]

Options:
  -o, --output-format      Output format (text|markdown) [default: text]
  -f, --file               Output file name
  --audit-upload           Send the output to the audits API
  --audit-base-url         API URL [default: https://codeaudits.ai/]
  --ignore-top-large-files Number of largest files to ignore [default: 0]
  --api-key               Your private API key for https://codeaudits.ai/
  -h, --help              Show this help message
```

### Examples

[](#examples)

```
# Analyze current directory with markdown output
php src/cli.php . -o markdown

# Save to specific file
php src/cli.php /path/to/project -f mydump.txt

# Ignore the 5 largest files
php src/cli.php /path/to/project --ignore-top-large-files 5

# Upload to Code Audits API
php src/cli.php /path/to/project --audit-upload --api-key YOUR_API_KEY
```

Features
--------

[](#features)

### Ignore Patterns

[](#ignore-patterns)

The tool supports the following default ignore patterns:

- **Python**: `*.pyc`, `*.pyo`, `*.pyd`, `__pycache__`
- **JavaScript**: `node_modules`, `bower_components`
- **Version Control**: `.git`, `.svn`, `.hg`, `.gitignore`
- **Virtual Environments**: `venv`, `.venv`, `env`
- **IDE**: `.idea`, `.vscode`
- **Temporary Files**: `*.log`, `*.bak`, `*.swp`, `*.tmp`
- **OS Files**: `.DS_Store`, `Thumbs.db`
- **Build**: `build`, `dist`, `*.egg-info`
- **Compiled Libraries**: `*.so`, `*.dylib`, `*.dll`

Additionally, the tool reads patterns from:

- `.gitignore` - Standard Git ignore patterns
- `.cdigestignore` - Custom ignore file (same format as `.gitignore`)

### Output Formats

[](#output-formats)

#### Text Format (Default)

[](#text-format-default)

Generates a plain text file with:

- Directory structure tree
- Summary statistics
- List of ignored files
- Full file contents

#### Markdown Format

[](#markdown-format)

Generates a Markdown file with:

- Directory structure tree
- Summary statistics
- List of ignored files
- File contents in code blocks

API Usage
---------

[](#api-usage)

You can also use the library programmatically in your PHP code:

```
