From 055a3a74f393ba95b0ce87f596c43f0bc0540da6 Mon Sep 17 00:00:00 2001 From: panariga Date: Mon, 27 Oct 2025 12:00:50 +0200 Subject: [PATCH] Add llmdumper.php --- llmdumper.php | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 llmdumper.php diff --git a/llmdumper.php b/llmdumper.php new file mode 100644 index 0000000..8dcf349 --- /dev/null +++ b/llmdumper.php @@ -0,0 +1,139 @@ +getRealPath(); + + // 1. Exclude the script itself and the output file. + if ($file->getBasename() === 'llmdumper.php' || $file->getBasename() === OUTPUT_FILE) { + continue; + } + + // 2. Exclude the entire 'vendor' directory. + // We check if the path contains '/vendor/'. + if (strpos($filePath, DIRECTORY_SEPARATOR . VENDOR_DIR . DIRECTORY_SEPARATOR) !== false) { + continue; + } + + // We only care about files, not directories. + if ($file->isDir()) { + continue; + } + + // 3. Exclude image files based on their extension. + $extension = strtolower($file->getExtension()); + if (in_array($extension, IMAGE_EXTENSIONS)) { + continue; + } + + // --- File Processing --- + + // Get the file path relative to the module's root directory. + $relativePath = str_replace($moduleRootPath . DIRECTORY_SEPARATOR, '', $filePath); + + // Prepend the module directory name to the relative path as requested. + $finalPath = $moduleDirName . DIRECTORY_SEPARATOR . $relativePath; + + // Read the file content. + $content = file_get_contents($filePath); + if ($content === false) { + echo "WARNING: Could not read file: {$finalPath}\n"; + continue; + } + + // Create a header for this file's content to identify it in the dump. + $fileHeader = " +//- - - - - - - - - - START: {$finalPath} - - - - - - - - - -// +"; + $fileFooter = " +//- - - - - - - - - - END: {$finalPath} - - - - - - - - - -// +\n"; + + // Assemble the full string to append to the output file. + $dumpContent = $fileHeader . $content . $fileFooter; + + // Append the content to the output file. + if (file_put_contents($outputFilePath, $dumpContent, FILE_APPEND)) { + echo "Appended: {$finalPath}\n"; + $totalBytes += strlen($dumpContent); + $fileCount++; + } else { + echo "ERROR: Could not write to output file!\n"; + exit(1); // Exit with an error code. + } +} + +echo "---------------------------------------------------\n"; +echo "Dump complete!\n"; +echo "- Files processed: {$fileCount}\n"; +echo "- Total size: " . round($totalBytes / 1024, 2) . " KB\n"; +echo "- Output file: {$outputFilePath}\n"; + +?> \ No newline at end of file