This document describes the multi-version support system added to phan-demo.
The phan-demo system has been enhanced to support multiple PHP and Phan version combinations that users can select via dropdown menus in the web UI.
- 8.1.31
- 8.2.27
- 8.3.16
- 8.4.2
- 8.5.0RC2
- 5.5.1 (latest stable release)
Note: Development versions (v5-dev, v6-dev) are currently disabled due to complexity in building phars from git. These may be added in a future update once the phar build process is properly debugged.
New multi-version build script that:
- Downloads Phan 5.5.1 release
- Builds each PHP version (8.1, 8.2, 8.3, 8.4, 8.5 RC2) with Phan 5.5.1
- Outputs to
builds/php-{VERSION}/phan-{VERSION}/directory structure - Handles special cases like PHP RC versions from maintainer directories
- Total of 5 builds (5 PHP versions × 1 Phan version)
- Added version selector dropdowns for PHP and Phan
- Updated to dynamically reference Phan phar path with
$PHAN_PHAR_PATHplaceholder - Removed static
php.jsscript tag (now loaded dynamically) - Added CSS styling for version selectors
- Dynamic loading of
php.jsfrom version-specific paths loadPHPScript()function to load correct php.js for selected versionreloadPHPModule()function to switch versions on-the-fly- Event listeners for version selector changes
- Path resolution via
getVersionPath()function
Added styling for:
.version-selectors- Container for version dropdowns.selector-wrapper- Individual selector styling- Labels and select elements with proper spacing and styling
- Updated
CLAUDE.mdwith multi-version build instructions - Added version configuration documentation
- Updated architecture section to describe dynamic loading
Added entries to ignore:
builds/directoryphan-git-*/directoriesphp-7.*sources
- Build Time:
build-multi.shcreates all version combinations inbuilds/directory - Load Time: JavaScript dynamically loads
php.jsfrom default version path (builds/php-84/phan-5.5.1/) - Runtime: User selects different versions via dropdowns
- Version Switch: JavaScript reloads PHP module with new version's binaries
phan-demo/
├── build-multi.sh # Multi-version build script
├── build.sh # Legacy single-version build
├── builds/ # Build output (gitignored)
│ ├── php-81/
│ │ ├── phan-5.5.1/
│ │ │ ├── php.wasm
│ │ │ ├── php.js
│ │ │ └── php.data
│ │ ├── phan-v5-dev/
│ │ └── phan-v6-dev/
│ ├── php-82/
│ │ └── ...
│ └── ...
├── index.html # Main UI with version selectors
├── static/
│ ├── demo.js # Version switching logic
│ └── demo.css # Version selector styling
└── CLAUDE.md # Updated documentation
docker run --rm -v $(pwd):/src emscripten/emsdk bash -c 'apt update && DEBIAN_FRONTEND=noninteractive apt install -y php-cli autoconf git composer; ./build-multi.sh'docker run --rm -v $(pwd):/src emscripten/emsdk bash -c 'apt update && DEBIAN_FRONTEND=noninteractive apt install -y php-cli autoconf; ./build.sh'- Build the desired versions
- Start local web server:
python3 -m http.server --bind 127.0.0.1 8080 - Open http://localhost:8080/
- Use version selectors to switch between PHP and Phan versions
- Test both "Analyze" and "Run" buttons with different version combinations
-
Update
build-multi.sh:PHP_VERSIONS=("8.1.31" "8.2.27" "8.3.16" "8.4.2" "8.5.0RC2" "8.6.0beta1")
-
Update
index.html:<select id="php-version"> ... <option value="86">8.6 beta1</option> </select>
- Update
build-multi.shwith new version variable - Add build call in main loop
- Update
index.htmldropdown
- Each build takes significant time (5-15 minutes per combination)
- Total build time: ~2-4 hours for all 15 combinations
- Disk space: ~500MB-1GB per build = 7.5-15GB total
- Browser loading: First load downloads selected version's WASM (~20-30MB)
- Version switching: Downloads new WASM files when switching versions
- Original
build.shstill works for single-version builds - Outputs to project root (legacy behavior)
- No breaking changes to existing deployments