This is a PHP interpreter written in Go, with a bytecode backend and an HTTP server built in. It runs a subset of the language and of the standard library. phpscript list --bindings prints the bindings this build holds, and phpscript info counts those bindings. The parts it does not run are decisions as often as gaps: see Design decisions for the rejected features and the language reference for the unimplemented ones.
One set of endpoints written six ways, each in a directory under testdata/, all driven by one load generator. GET /hello at concurrency 1, four workers a side, four cores, six segments of 3s, measured on 2f756154 by scripts/benchmark.php:
| Runtime | /hello |
p90 us | p99 us |
|---|---|---|---|
goserver, net/http and no VM, the floor |
26006 req/s, 35 us/req | 44 | 141 |
phpscript-http-bridge, a PHP program that is the server |
21595 req/s, 42 us/req | 52 | 192 |
phpscript-go-runtime-server, the same server under runtime: go |
21734 req/s, 42 us/req | 52 | 173 |
phpscript-service, @route endpoints under phpscript server |
12081 req/s, 73 us/req | 99 | 402 |
php-vanilla, Slim on nginx with php-fpm |
2429 req/s, 383 us/req | 496 | 900 |
php-vanilla, Slim on apache with mod_php |
2128 req/s, 446 us/req | 514 | 860 |
Each directory's README explains the numbers and the per-request cost of the stack. phpscript-http-bridge, phpscript-go-runtime-server and phpscript-service answer under three execution models: Path B twice, once with use Runtime\Go; per file and once with runner.runtime: go, then Path A. This one goes stale the moment either path changes. It names the commit it describes, and these two commands write it again:
BENCH_TARGETS="goserver bridge goruntime service vanilla-apache vanilla-nginx" scripts/bench-http.sh after
scripts/benchmark.php- About phpscript
- Design decisions
- Language reference and PHP compatibility
- Installation and CLI reference
- Configuration
- Security
- Testing and extending tests
- Test fixture results
- Code coverage
- Naming conventions
- Adding a binding, start to finish
- Glossary
- Go Reference
- Building an application
- Use cases
.phpt fixtures settle behaviour: each starts by running the source through real php, and phpscript test --matrix ./tests/... checks runtime output against php output on both engines and on php itself. The test fixture results come out of that run and hold every fixture, its area and three columns. A table copied into this page goes stale the moment an area grows, as this one did.
atkins test:detail collects a coverage profile, and atkins cover folds it into splint's document of the tree to render the generated code coverage report, per package, with the detail per function. Each row lists the cognitive complexity and the line count next to the percentage. A low number says whether there is a branch left to cover or nothing to cover at all.
Those three documents change on every run. .gitignore holds them. atkins gen writes the set, and atkins publish attaches it to the release, where the links above resolve.
You can build a docker image from source as follows:
CGO_ENABLED=0 go build -o bin/ .
docker build -t titpetric/phpscript:latest -f docker/Dockerfile .
See ./compose.yml for usage.
Contributions welcome. Open an issue to discuss before opening PRs.