4.1 KiB
LLM Dumper for PrestaShop Modules
A simple, zero-dependency PHP script to aggregate all meaningful source code from a PrestaShop module into a single text file. This tool is designed to make it easy to copy-paste an entire module's codebase into the context window of a Large Language Model (LLM) like GPT-4, Claude, or Llama.
The Problem It Solves
When working with LLMs for code analysis, debugging, or documentation, you often need to provide the full source code of a project as context. For a typical PrestaShop module, this involves opening dozens of files (.php, .tpl, .js, .css, etc.) and pasting them one by one. This is tedious, error-prone, and inefficient.
This script automates that process, creating a single, well-structured text file containing all relevant code, ready to be fed to an LLM.
Features
- Recursive Scanning: Scans the entire module directory, including all subdirectories.
- Intelligent Exclusions: Automatically ignores:
- The
vendordirectory (Composer dependencies). - Common image file types (
.png,.jpg,.svg, etc.). - The script itself (
llmdumper.php). - The generated output file (
.llmdump).
- The
- Clear Context: Prepends each file's content with a header containing its relative path (e.g.,
myawesomemodule/controllers/front/main.php). - Single File Output: Creates one easy-to-manage
.llmdumpfile. - Command-Line Friendly: Provides progress feedback as it runs.
How to Use
-
Download: Place the
llmdumper.phpscript into the root directory of the PrestaShop module you want to dump./prestashop └── /modules └── /myawesomemodule <-- Place the script here ├── llmdumper.php ├── myawesomemodule.php ├── config.xml └── /views └── ... -
Navigate: Open your terminal or command prompt and navigate to the module's directory.
cd /path/to/prestashop/modules/myawesomemodule -
Execute: Run the script using PHP.
php llmdumper.phpYou will see a list of files being appended to the dump.
-
Find the Output: A hidden file named
.llmdumpwill be created in the module's root directory. -
Use the Content: Open
.llmdumpin a text editor, select all (Ctrl+A / Cmd+A), copy the contents, and paste it into your LLM prompt. -
CLEAN UP: This is the most important step. After you are done, delete both files from your server.
rm llmdumper.php .llmdump
⚠️ Security Warning ⚠️
- This script is intended for use in a local development environment only.
- The generated
.llmdumpfile contains your module's entire source code. - If you run this script on a live, public-facing web server, the
.llmdumpfile could potentially be downloaded by anyone if your server is not configured to block access to dotfiles. - Always delete
llmdumper.phpand.llmdumpimmediately after use.
Example Output
The generated .llmdump file will look like this:
//- - - - - - - - - - START: myawesomemodule/myawesomemodule.php - - - - - - - - - -//
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
class MyAwesomeModule extends Module
{
// ... module class content ...
}
//- - - - - - - - - - END: myawesomemodule/myawesomemodule.php - - - - - - - - - -//
//- - - - - - - - - - START: myawesomemodule/views/templates/hook/displayHome.tpl - - - - - - - - - -//
<div class="awesome-block">
<p>{l s='This is an awesome module!' mod='myawesomemodule'}</p>
</div>
//- - - - - - - - - - END: myawesomemodule/views/templates/hook/displayHome.tpl - - - - - - - - - -//
Configuration
The script has a few constants at the top that you can modify if needed:
OUTPUT_FILE: Change the name of the output file (default:.llmdump).VENDOR_DIR: Change the name of the vendor directory to exclude (default:vendor).IMAGE_EXTENSIONS: Add or remove file extensions to be treated as non-text/image files.
License
This project is licensed under the MIT License.