This document describes the organization and purpose of each folder and file in the Project Structure Viewer library.
project-structure-viewer/
├── src/ # Main source code directory
├── public/ # Web-accessible files
├── install/ # Installation and setup scripts
├── tests/ # Unit tests (future)
├── composer.json # Composer configuration and dependencies
├── LICENSE # MIT license file
├── README.md # Main documentation and usage guide
├── structure.md # This file - project structure documentation
├── features.md # Feature list and implementation status
└── task_pending.md # Pending tasks and future improvements
ProjectStructureViewer.php- Main library class that orchestrates the entire functionality- Handles directory scanning and structure generation
- Provides multiple output formats (HTML, JSON, Array)
- Manages gitignore integration
- Offers static factory methods for easy instantiation
GitignoreParser.php- Handles .gitignore file parsing and pattern matching- Loads and parses .gitignore rules
- Converts gitignore patterns to regex
- Provides path filtering functionality
- Supports negation patterns and complex gitignore syntax
-
HtmlRenderer.php- Generates interactive HTML output- Creates complete HTML pages with embedded CSS and JavaScript
- Provides VS Code-inspired dark theme
- Includes responsive design for mobile devices
- Handles tree structure rendering with expand/collapse functionality
-
JsonRenderer.php- Generates JSON output in various formats- Standard JSON with metadata and statistics
- Compact JSON (structure only)
- Flat JSON (all paths in single array)
- Calculates project statistics (file counts, sizes, extensions)
index.php- Web entry point for automatic URL access- Handles http://localhost/structure-project requests
- Auto-detects project root directory
- Provides security checks and error handling
- Supports multiple output formats via query parameters
- Includes comprehensive error pages with troubleshooting
setup.php- Post-installation configuration script- Runs automatically after
composer install - Sets up automatic web URL access
- Creates necessary directories and files
- Provides usage instructions and examples
- Handles different web server configurations
- Runs automatically after
- Package metadata and dependencies
- PSR-4 autoloading configuration
- Post-install scripts
- Development dependencies (PHPUnit)
- Packagist publishing information
- MIT license terms
- Copyright information
- Usage permissions and limitations
- Complete usage guide and API documentation
- Installation instructions
- Framework integration examples
- Feature overview and screenshots
- Contributing guidelines
- Detailed project structure explanation
- File and directory purposes
- Architecture overview
- Implemented features list
- Feature status and completion
- Technical specifications
- Future improvements and enhancements
- Bug fixes and optimizations
- Community feature requests
- Single Responsibility: Each class has a specific, well-defined purpose
- Framework Independence: No external framework dependencies
- Extensibility: Easy to add new renderers and output formats
- Security First: Built-in security checks and validations
- PSR Standards: Follows PSR-4 autoloading and PSR-12 coding standards
ProjectStructureViewerscans directory structureGitignoreParserfilters files based on .gitignore rules- Structure data is passed to appropriate renderer
- Renderer generates final output (HTML, JSON, etc.)
- Output is returned to user or displayed in browser
- Scanner: Directory traversal and file information gathering
- Filter: Gitignore-based file filtering
- Renderer: Output format generation
- Security: Path validation and access control
- Web Interface: Browser-based access and interaction
- Classes: PascalCase (e.g.,
ProjectStructureViewer.php) - Namespaces: Follow PSR-4 standards
- Methods: camelCase with descriptive names
- Constants: UPPER_SNAKE_CASE
- Files: kebab-case for documentation, PascalCase for classes
- PHP 8.0+: Modern PHP features and type declarations
- Composer: Autoloading and package management
- PHPUnit: Unit testing framework (future implementation)
The library is designed to work without external dependencies to ensure:
- Maximum compatibility
- Minimal installation footprint
- Reduced security surface
- Framework independence