This directory contains working examples demonstrating how to use php-universe to build applications for different platforms.
1. Hello World
The simplest possible php-universe application. Perfect for getting started.
What it demonstrates:
- Basic PHP functions
- CLI entry point
- Simple configuration
Run it:
cd hello-world
composer install
px build --target=native
./dist/hello-world "PHP Universe"2. CLI Tool
A command-line file processor that analyzes files and works as a native binary.
What it demonstrates:
- File I/O operations
- Error handling
- CLI argument parsing
- Formatted output
Run it:
cd cli-tool
composer install
px build --target=native
./dist/file-processor README.mdA calculator that runs entirely in the browser using WebAssembly.
What it demonstrates:
- WebAssembly compilation
- Function exports
- Browser integration
- Error handling
Run it:
cd wasm-calculator
composer install
px build --target=wasm
# Serve index.html with an HTTP server
python3 -m http.server 8000
# Open http://localhost:8000/index.htmlA math library that works on all platforms (Native, WASM, iOS, Embedded).
What it demonstrates:
- Platform-agnostic code
- Pure functions
- Multi-target compilation
- Library design
Run it:
cd cross-platform-lib
composer install
px build --target=native
./dist/math-lib fibonacci 10- Choose an example that matches what you want to build
- Navigate to the example directory
- Install dependencies:
composer install - Build for your target:
px build --target=<target> - Run and test: Follow the example's README
Each example includes a universe.toml configuration file. You can enable/disable targets as needed:
# Build for native
px build --target=native
# Build for WebAssembly
px build --target=wasm
# Build for iOS (requires macOS/Xcode)
px build --target=ios
# Build for embedded device
px build --target=embedded
# Build all enabled targets
px build --allEach example follows this structure:
example-name/
├── src/ # Source code
│ └── *.php # PHP files
├── universe.toml # Build configuration
├── composer.json # PHP dependencies
├── README.md # Example-specific documentation
└── dist/ # Build output (generated)
- Read the main README for overview
- Check TOOLS.md for tool documentation
- See EXAMPLES.md for more code examples
- Review CONTRIBUTING.md to contribute
Have questions? Open an issue on GitHub or check the documentation files.