A lightweight PHP static site generator for GitHub projects that creates a professional documentation website with minimal configuration.
Overview
This tool automatically generates a static website based on your GitHub repository content. It pulls README.md and other Markdown files from your repo, converts them to HTML, and creates a fully functioning website with navigation, download page, and support functionality.
Features
- [x] Home page generated from
README.md
- [x] Additional Markdown pages (e.g.,
INSTALLATION.md
,TROUBLESHOOTING.md
) - [x] Download page with GitHub Releases information
- [x] Support page with:
- List of open GitHub issues
- Contact form with email notifications
- [x] Code syntax highlighting with highlight.js
- [x] Sponsor page with donation links from GitHub FUNDING.yml
Future Plans
- Local caching for faster generation
- Favicon customization
- Theme customization options
See in action
Installation
- Clone this repository:
git clone https://github.com/magicoli/php-site-generator.git cd php-site-generator
- Install dependencies:
composer install
- Create configuration file:
cp config.json.example config.json
- Edit
config.json
with your project details
- Generate the site:
php generate.php
- Set up a cron task to automatically update your site:
# Edit crontab crontab -e
Add a line to run the generator hourly (adjust the path as needed)
0 cd /home/path/to/php-site-generator && php generate.php >> /var/log/site-generator.log 2>&1
The cron task will automatically rebuild your site on a regular schedule, keeping the content in sync with your GitHub repository.
Configuration
Edit config.json
to configure your site:
{
"title": "My GitHub Project",
"github_user": "user",
"repo": "my-repo",
"github_branch": "master",
"github_token": "your_token_here",
"support_email": "support@example.com",
"sender_email": "noreply@example.com",
"output_folder": "output",
"menu": [
{ "title": "About", "file": "/" },
{ "title": "Download", "file": "download" },
{ "title": "Installation", "file": "INSTALLATION.md" },
{ "title": "Troubleshooting", "file": "TROUBLESHOOTING.md" },
{ "title": "Support", "file": "support" }
]
}
Important configuration options:
github_token
: Optional, helps avoid API rate limitationssupport_email
: Required for the support form to functionsender_email
: Optional, defaults to support_email if not setoutput_folder
: your website root directory (e.g. /var/www/html)
Project Structure
/php-site-generator/
├── config.json // Configuration for the site and pages
├── generate.php // Main script to generate the static site
├── template.php // HTML template for the pages
├── vendor/ // Composer dependencies (Parsedown)
├── assets/ // CSS, images
│ └── style.css // Custom styling
└── pages/ // Local Markdown files and templates
├── download.md // Template for download page
├── support.md // Template for support page
└── partials/ // Reusable page components
└── support_form.php // Support form template
../www/ // Generated static site (output folder defined in config.json) ├── assets │ └── style.css ├── download.html ├── index.html ├── installation.html ├── support.php // PHP for dynamic support form ├── support_form.php // Included in support.php └── troubleshooting.html
How It Works
The generate.php
script:
- Loads your configuration
- Fetches content from your GitHub repository
- Processes Markdown files into HTML
- Creates special pages like download and support
- Assembles a complete website with navigation
- Outputs everything to your specified folder
License
AGPL-3.0
Credits
- Parsedown for Markdown parsing
- Bootstrap for responsive layout
- highlight.js for code syntax highlighting