|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is **jbzoo/composer-graph**, a PHP CLI tool that renders dependency graphs from composer.json and composer.lock files. It generates HTML visualizations using Mermaid.js to display package dependencies, PHP extensions, dev dependencies, and suggested packages. |
| 8 | + |
| 9 | +## Development Commands |
| 10 | + |
| 11 | +### Primary Commands |
| 12 | +- `make update` - Install/update all dependencies using Composer |
| 13 | +- `make build` - Install dependencies and build PHAR file |
| 14 | +- `make test-all` - Run full test suite and code style checks |
| 15 | +- `make test` - Run PHPUnit tests only |
| 16 | +- `make codestyle` - Run code style checks and fixes |
| 17 | + |
| 18 | +### Testing |
| 19 | +- `vendor/bin/phpunit` - Run PHPUnit tests directly |
| 20 | +- Tests are in `tests/` directory with fixtures in `tests/fixtures/` |
| 21 | +- PHPUnit configuration in `phpunit.xml.dist` |
| 22 | + |
| 23 | +### Code Quality Tools |
| 24 | +The project uses `jbzoo/toolbox-dev` which provides various code quality tools: |
| 25 | +- `vendor/bin/php-cs-fixer` - PHP CS Fixer for code formatting |
| 26 | +- `vendor/bin/phan` - Static analysis |
| 27 | +- Various other tools available in `vendor/bin/` |
| 28 | + |
| 29 | +## Architecture |
| 30 | + |
| 31 | +### Core Classes |
| 32 | +- **`ComposerGraph`** (`src/ComposerGraph.php`) - Main class that builds dependency graphs using Mermaid.js |
| 33 | +- **`Collection`** (`src/Collection.php`) - Manages packages and their relationships |
| 34 | +- **`Package`** (`src/Package.php`) - Represents individual packages with dependencies |
| 35 | +- **`Helper`** (`src/Helper.php`) - Utility functions for package processing |
| 36 | +- **`Commands/Build`** (`src/Commands/Build.php`) - CLI command implementation using JBZoo CLI framework |
| 37 | + |
| 38 | +### Key Dependencies |
| 39 | +- **JBZoo Libraries**: Uses `jbzoo/cli`, `jbzoo/mermaid-php`, `jbzoo/data`, `jbzoo/utils` |
| 40 | +- **Symfony Console**: For CLI interface (`symfony/console`) |
| 41 | +- **Mermaid.js**: Graph visualization via `jbzoo/mermaid-php` wrapper |
| 42 | + |
| 43 | +### Main Flow |
| 44 | +1. Parse `composer.json` and `composer.lock` files from specified root directory |
| 45 | +2. Build package collection with dependencies, dev dependencies, extensions |
| 46 | +3. Generate Mermaid.js graph syntax with nodes and links |
| 47 | +4. Output as HTML file with embedded Mermaid visualization or raw Mermaid format |
| 48 | + |
| 49 | +### Binary Entry Points |
| 50 | +- `composer-graph` - Shell script wrapper |
| 51 | +- `composer-graph.php` - Main PHP entry point |
| 52 | +- PHAR file is built for distribution |
| 53 | + |
| 54 | +## File Structure |
| 55 | +- `src/` - Main source code (PSR-4: JBZoo\ComposerGraph namespace) |
| 56 | +- `tests/` - PHPUnit tests with fixture projects |
| 57 | +- `resources/` - Example images and assets |
| 58 | +- `build/` - Build artifacts and reports |
| 59 | +- `Makefile` - Development commands (includes jbzoo/codestyle tasks) |
0 commit comments