PHPackages                             mapali/codex-dump - 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. mapali/codex-dump

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

mapali/codex-dump
=================

Export all PHP files in a Laravel codebase into a single file for AI ingestion or analysis.

v1.0.2(1y ago)15MITPHPPHP ^8.2

Since May 18Pushed 1y ago1 watchersCompare

[ Source](https://github.com/matt-lickess/codex-dump)[ Packagist](https://packagist.org/packages/mapali/codex-dump)[ RSS](/packages/mapali-codex-dump/feed)WikiDiscussions main Synced 1mo ago

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

Codex Dump for Laravel
======================

[](#codex-dump-for-laravel)

Codex Dump is a Laravel package designed to consolidate and export your project's PHP source files into a single structured text file. This streamlined output serves as optimized context input for AI-driven code assistance tools like ChatGPT, Codex, or similar systems.

Features
--------

[](#features)

- **Selective Export:** Define directories and file types to include or exclude.
- **Token Management:** Prevents exceeding AI token limits by providing token estimations and configurable maximum limits.
- **Persistent History:** Remembers previously used directories and file paths for rapid reuse.
- **Interactive CLI:** Offers intuitive prompts for quick and accurate configuration.
- **Automatic File Structure:** Clearly documents the exported file structure for easy AI interpretation.

---

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

[](#installation)

Install using Composer:

```
composer require mapali/codex-dump --dev
```

Publish the configuration (optional):

```
php artisan vendor:publish --provider="Mapali\CodexDump\CodexDumpServiceProvider" --tag="config"
```

---

Configuration
-------------

[](#configuration)

By default, the package exports all `.php` files, excluding commonly ignored directories (`vendor`, `node_modules`, `.git`, `storage`). Customize these options via `config/codex-dump.php`:

```
return [
    'ignore_dirs' => [
        'vendor',
        'node_modules',
        'storage',
        '.git',
    ],

    'extensions' => [
        'php',
    ],

    'default_output' => base_path('codex_dump.txt'),
    'max_tokens' => 10000,
];
```

- **`ignore_dirs`**: Directories to skip.
- **`extensions`**: File extensions to include.
- **`default_output`**: Default path for the exported text file.
- **`max_tokens`**: Maximum allowed tokens to ensure compatibility with AI models.

---

Usage
-----

[](#usage)

To export your project's codebase, run:

```
php artisan codex:dump
```

You'll be interactively prompted for:

- **Base directory:** Directory path to scan (default: current directory).
- **Output file path:** Path for the resulting `.txt` file.

The package will then:

- Calculate the estimated token usage.
- Validate against configured token limits.
- Generate a neatly structured `.txt` file containing your project's files, clearly delineated for optimal AI ingestion.

Example output structure:

```
>>> FILE TREE
├── src/
│   ├── Commands/
│   │   └── DumpCodebaseCommand.php
│   └── Support/
│       └── CodexDumper.php

>>> src/Commands/DumpCodebaseCommand.php
