Skip to content
titpetricPublic

About

phpscript - an inter-operable PHP syntax VM written in Go (no CGO).

Resources

Security policy

Stars

12 stars

Watchers

0 watching

Forks

Latest commit

 

History

580 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

phpscript - A custom PHP-flavoured runtime written in Go

This is a PHP interpreter written in Go, with a bytecode backend beside it and an HTTP server of its own. It runs a subset of the language and of the standard library - phpscript list --bindings prints what this build carries, and phpscript info counts it - and the parts it does not run are decisions as often as gaps: see Design decisions for what it won't build and the language reference for what it does not run yet.

One API, five runtimes

One set of endpoints written five ways, each its own 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 669f5c9 by scripts/bench-http.sh:

Runtime /hello p90 us p99 us
goserver, net/http and no VM, the floor 26719 req/s, 35 us/req 41 106
phpscript-http-bridge, a PHP program that is the server 19441 req/s, 47 us/req 56 161
phpscript-service, @route endpoints under phpscript server 13089 req/s, 70 us/req 87 291
php-vanilla, Slim on nginx with php-fpm 2525 req/s, 373 us/req 466 725
php-vanilla, Slim on apache with mod_php 2017 req/s, 472 us/req 562 801

Each directory's README states what its numbers mean and what its stack costs per request. phpscript-http-bridge and phpscript-service answer under two different execution models, Path B and Path A, and the comparison sets out which figures belong in a table together. This one goes stale the moment either path changes, so it carries the commit it describes, and these two commands write it again:

BENCH_TARGETS="goserver bridge service vanilla-apache vanilla-nginx" scripts/bench-http.sh after
scripts/benchmark.php

Current state

.phpt fixtures settle behaviour: each one starts by running the source through real php, and phpscript test --matrix ./tests/... checks the runtime against that output on both engines and on php itself. The test fixture results come out of that run and hold every fixture, its area and the three columns. A table copied into this page goes stale the moment an area grows, as this one did.

The Go test run 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 carries the cognitive complexity and the line count beside the percentage, so a low number says whether there is a branch left to cover or nothing to cover at all. atkins gen:coverage:dbadmin measures the dbadmin demo the same way from a running server, in dbadmin.md.

Those five documents change on every run, so .gitignore holds them: atkins gen writes them and atkins publish attaches them to the release, where the links above resolve to.

Building a docker image

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.

Contributing

Contributions welcome. Open an issue to discuss before opening PRs.

About

phpscript - an inter-operable PHP syntax VM written in Go (no CGO).

Resources

Security policy

Stars

12 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages