An open-source PHP documentation & data exploration platform by Mark Hazleton (WebSpark suite) showcasing hybrid server-side + modern asset pipeline techniques.
Educational Focus: This project serves as a comprehensive reference implementation for building modern PHP applications with contemporary tooling, showcasing patterns for documentation management, data visualization, API integration, and responsive UI development.
- π― Project Overview
- β¨ Key Features
- ποΈ Architecture
- π§ Technology Stack
- π Quick Start
- π Project Structure
- π οΈ Development
- π Build System
- π§ͺ Features Showcase
- π Deployment
- π Documentation
- π€ Contributing
- π Performance
- π Security
- π License
PHPDocSpark demonstrates modern PHP web development practices by building a comprehensive documentation and portfolio platform. It integrates traditional server-side PHP with a contemporary client-side build toolchain, creating a hybrid architecture that leverages the best of both worlds.
- Modern PHP Development: PHP 8.2+ features, clean architecture patterns
- Hybrid Build System: Vite-powered asset pipeline with PHP backend
- Content Management: Markdown-based documentation with full-text search
- Data Visualization: Interactive charts and data analysis tools
- API Integration: GitHub API, external services, caching strategies
- Responsive Design: Bootstrap 5, mobile-first approach
- DevOps: Azure Pipelines, automated deployment workflows
- Brand Integration: Part of the WebSpark suite (https://webspark.markhazleton.com)
- PHP developers exploring modern development workflows
- Full-stack developers interested in hybrid architectures
- Technical writers and documentation maintainers
- Students learning web development best practices
- Teams seeking reference implementations for internal tools
- Modern Build System: Vite 7.1+ with hot module replacement
- Responsive Design: Bootstrap 5.3 with custom SCSS compilation
- Interactive Components: DataTables, Chart.js integration
- Asset Optimization: Automated minification, compression, source maps
- Markdown Documentation: Recursive directory scanning with Parsedown
- Full-Text Search: File content indexing with relevance scoring
- Dynamic Navigation: Auto-generated menus from file structure
- Content Caching: Performance-optimized file serving
- CSV Analysis: Automatic field statistics and data profiling
- Interactive Tables: Sortable, filterable data grids
- Chart Generation: Dynamic visualization with Chart.js
- Export Capabilities: Multiple format support (CSV, Excel, PDF ready)
- GitHub Integration: Repository stats, commit history, contributor data
- External APIs: JokeAPI demo with error handling
- Caching Layer: JSON-based response caching with TTL
- Rate Limiting: Built-in API call optimization
- SQLite Integration: Zero-configuration database setup
- CRUD Operations: Complete contact management system
- Data Seeding: Sample data population for testing
- Duplicate Prevention: Smart data validation logic
graph TB
A[Client Browser] --> B[PHP Front Controller]
B --> C[Page Router]
C --> D[Feature Pages]
D --> E[Layout System]
E --> F[Built Assets]
G[Vite Build System] --> F
H[SCSS/JS Sources] --> G
D --> I[SQLite Database]
D --> J[File System]
D --> K[External APIs]
L[Azure Pipeline] --> M[Azure Web App]
B --> M
- Routing: Clean URL handling via
index.php
front controller - Page Logic: Feature-specific PHP scripts with embedded HTML
- Layout Composition: Output buffering for template inheritance
- Asset Delivery: Optimized CSS/JS via Vite build pipeline
- Data Sources: SQLite, Markdown files, JSON, external APIs
Component | Technology | Version | Purpose |
---|---|---|---|
Runtime | PHP | 8.2+ | Server-side logic, templating |
Database | SQLite | 3.x | Embedded database, zero config |
Parser | Parsedown | Latest | Markdown to HTML conversion |
Server | PHP Built-in | 8.2+ | Development server |
Component | Technology | Version | Purpose |
---|---|---|---|
Build Tool | Vite | 7.1+ | Asset bundling, HMR |
CSS Framework | Bootstrap | 5.3.7 | Responsive design system |
Icons | Bootstrap Icons | 1.13+ | Scalable icon library |
JavaScript | jQuery | 3.7+ | DOM manipulation, AJAX |
Data Tables | DataTables | 2.3+ | Interactive table enhancement |
Charts | Chart.js | Latest | Data visualization |
Component | Technology | Version | Purpose |
---|---|---|---|
CSS Preprocessing | Sass | 1.90+ | Advanced CSS features |
Linting | ESLint | 9.15+ | JavaScript code quality |
Formatting | Prettier | 3.3+ | Code formatting |
CI/CD | Azure Pipelines | Latest | Automated deployment |
Hosting | Azure Web Apps | Linux | Production hosting |
- PHP 8.2+ with SQLite extension
- Node.js 18+ and npm 8+
- Git for version control
git clone https://github.com/markhazleton/PHPDocSpark.git
cd documents
# Install dependencies
composer install # PHP dependencies
npm install # Node.js dependencies
# Development build with watching
npm run dev
# Or full development server (recommended)
npm run dev:serve # Builds assets + starts PHP server
Open http://localhost:8001 in your browser.
# Build assets once
npm run build
# Start PHP server
cd website
php -S localhost:8001
documents/
βββ π src/ # Frontend source files
β βββ main.js # Vite entry point
β βββ π css/ # SCSS stylesheets
β β βββ site.scss # Main stylesheet
β β βββ custom.scss # Custom components
β β βββ vendor.scss # Third-party styles
β βββ π js/ # JavaScript modules
β βββ custom.js # Custom functionality
β βββ vendor.js # Third-party libraries
β
βββ π website/ # PHP application root
β βββ index.php # Front controller & router
β βββ layout.php # Main template layout
β βββ π pages/ # Feature implementations
β β βββ document_view.php # Markdown viewer
β β βββ data-analysis.php # CSV analysis
β β βββ database.php # CRUD operations
β β βββ project_list.php # Portfolio showcase
β β βββ github.php # GitHub integration
β β βββ search.php # Full-text search
β β βββ joke.php # API demo
β βββ π assets/ # Built assets (generated)
β β βββ css/site.css # Compiled stylesheets
β β βββ js/site.js # Bundled JavaScript
β β βββ fonts/ # Font files
β β βββ images/ # Optimized images
β β βββ π markdown/ # Documentation content
β β βββ π PHP/ # PHP documentation
β β βββ π Git/ # Git guides
β β βββ π ChatGPT/ # AI assistance docs
β β βββ π Build/ # Build system docs
β βββ π data/ # Application data
β βββ database.db # SQLite database
β βββ projects.json # Portfolio data
β βββ commits_cache.json # GitHub API cache
β βββ *.csv # Sample datasets
β
βββ π scripts/ # Build automation
β βββ build.js # Custom build script
βββ π .github/ # GitHub configuration
β βββ copilot-instructions.md # AI assistant config
βββ azure-pipelines.yml # CI/CD pipeline
βββ vite.config.js # Vite configuration
βββ package.json # Node.js dependencies
βββ composer.json # PHP dependencies
βββ README.md # This file
npm run dev # Build assets with file watching
npm run dev:serve # Build + serve (recommended for development)
npm run serve # Start PHP development server only
npm run build # Production build with optimizations
npm run build:prod # Production build with NODE_ENV set
npm run start # Clean + build + serve pipeline
npm run lint:js # Lint JavaScript with ESLint
npm run lint:css # Lint SCSS with Stylelint
npm run format # Format code with Prettier
npm run clean # Remove built assets
composer install # Update PHP dependencies
-
Start Development Server:
npm run dev:serve
-
Make Changes: Edit files in
src/
(assets) orwebsite/
(PHP) -
Asset Changes: Automatically rebuilt and browser-refreshed
-
PHP Changes: Refresh browser manually
-
Before Committing:
npm run format # Format code npm run build # Test production build
The project uses Vite as its build system, providing:
- β‘ Lightning Fast: Sub-second rebuilds with HMR
- π― Optimized Output: Minification, tree-shaking, code splitting
- π§ SCSS Processing: Advanced CSS features with Bootstrap integration
- π¦ Smart Bundling: Vendor chunks, asset optimization
- πΊοΈ Source Maps: Development debugging support
// vite.config.js - Key features:
{
build: {
rollupOptions: {
output: {
entryFileNames: 'js/site.js', // Consistent naming
assetFileNames: 'css/site.css', // Organized output
}
},
minify: 'terser', // Advanced minification
sourcemap: isDev, // Conditional source maps
},
css: {
preprocessorOptions: {
scss: {
includePaths: ['node_modules'], // Library imports
silenceDeprecations: ['legacy-js-api']
}
}
}
}
- Build Time: ~3.8 seconds (production)
- CSS Output: 320.77 kB β 47.28 kB (gzipped, 85% reduction)
- JS Output: 273.21 kB β 87.87 kB (gzipped, 68% reduction)
- Total Assets: ~1.2 MB β ~200 kB (transferred)
- Markdown Rendering: Parsedown integration with syntax highlighting
- Dynamic Navigation: Auto-generated from folder structure
- File Organization: Hierarchical content with optgroups
- Performance: Cached file scanning with lazy loading
- Full-Text Search: Content indexing across all markdown files
- Relevance Scoring: Frequency-based result ranking
- Context Highlighting: Search term emphasis with surrounding context
- Performance: File modification tracking for cache invalidation
- CSV Processing: Automatic field detection and statistics
- Data Profiling: Min/max/average calculations, frequency analysis
- Interactive Tables: Sortable, filterable with DataTables
- Export Ready: Infrastructure for multiple format downloads
- SQLite Integration: Auto-creation with migration logic
- Contact Management: Full CRUD with duplicate prevention
- Data Seeding: Star Trek character sample data
- UI Components: Modal editing, inline forms, confirmation dialogs
- JSON-Driven: Configurable project cards with metadata
- Filtering: Live search and category filters
- Responsive Layout: Bootstrap grid with mobile optimization
- Image Optimization: Lazy loading and responsive images
- Repository Stats: Commits, contributors, file counts
- Commit History: Recent commits with file change deltas
- API Caching: 1-hour TTL with timestamp display
- Error Handling: Graceful fallbacks for API failures
- External Integration: JokeAPI with cURL implementation
- AJAX Interface: Dynamic content updates with fade transitions
- Session Tracking: Joke counter with statistics
- Error Recovery: Network failure handling with user feedback
The project includes a complete CI/CD pipeline via azure-pipelines.yml
:
# Production deployment workflow:
trigger: [main]
stages:
- stage: Build
- PHP 8.1 setup
- Composer install
- Asset compilation
- Archive website/ folder
- stage: Deploy
- Azure Web App deployment
- Zero-downtime deployment
- Health checks
- Production: phpdocspark.azurewebsites.net
- Platform: Azure Web Apps (Linux)
- PHP Version: 8.1+
- Deployment: Automated via Azure DevOps
# 1. Build production assets
npm run build
# 2. Archive website folder
zip -r site.zip website/
# 3. Deploy via Azure CLI (if configured)
az webapp deployment source config-zip \
--resource-group controlorigins \
--name controlorigins-docs \
--src site.zip
- Architecture Guide: /website/assets/markdown/Build/
- PHP Guidelines: /website/assets/markdown/PHP/
- Git Workflow: /website/assets/markdown/Git/
- AI Integration: /website/assets/markdown/ChatGPT/
- Blog Article: Creating a PHP Website with ChatGPT
- Story Origin: The Code Conjurer
- PHP Documentation: php.net
- Vite Guide: vitejs.dev
We welcome contributions! This project serves as an educational resource, so improvements that enhance learning value are especially appreciated.
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Make changes following existing patterns
- Test across different PHP versions
- Format code:
npm run format
- Submit a pull request
- Code Style: Follow existing PHP and JavaScript patterns
- Documentation: Update README and inline docs for new features
- Testing: Manually test all affected functionality
- Compatibility: Ensure PHP 8.0+ and modern browser support
- Performance: Consider impact on build times and runtime
- Unit test coverage (PHPUnit integration)
- Accessibility improvements (ARIA labels, keyboard nav)
- Performance optimizations (caching, lazy loading)
- Security enhancements (input validation, CSRF protection)
- Mobile experience improvements
- Time to First Byte: < 200ms (average)
- First Contentful Paint: < 1.2s
- Largest Contentful Paint: < 2.5s
- Cumulative Layout Shift: < 0.1
- Asset Bundling: Vite-optimized CSS/JS delivery
- Image Optimization: WebP format support ready
- Caching Strategy: File-based caching for API responses
- Database: SQLite for zero-config performance
- CDN Ready: Asset structure prepared for CDN deployment
- Input Validation: Allow-list routing prevents arbitrary file inclusion
- SQL Injection Prevention: PDO prepared statements throughout
- XSS Protection: HTML escaping with
htmlspecialchars()
- Dependency Security: Regular updates via npm audit
- CSRF Protection: Add token validation for forms
- Content Security Policy: Implement CSP headers
- Rate Limiting: Add API call throttling
- Environment Variables: Move secrets out of code
- HTTPS Enforcement: SSL-only in production
Released under the MIT License β see LICENSE for full text.
Copyright (c) Mark Hazleton.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- PHP Community: For excellent documentation and best practices
- Vite Team: For revolutionary build tooling
- Bootstrap Team: For consistent, beautiful UI components
- Azure Team: For reliable cloud hosting and DevOps tools
- Open Source Community: For the amazing ecosystem we build upon
π Live Demo | π Documentation | π§ GitHub Issues
Built with β€οΈ by Mark Hazleton