phpscript

command module
v0.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 22 Imported by: 0

README

phpscript - A custom PHP-flavoured runtime written in Go

This is an experimental PHP interpreter. It supports the basic php expression syntax and some parts of the standard library. It's currently very rudimentary and only enables limited functionality.

Current state

Several unit focused test fixtures exists, namely:

  1. interfacing Go code from the PHP VM for callbacks,
  2. database client and usage from PHP side (bring your own database/sql driver)
  3. loading and executing template engine code

This means that phpscript is currently able to use a generic Database client. Our own standard library implements a Database class which is integration tested with ./tests/fixtures/test-database.php over several databases (pgx, mysql, sqlite).

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.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
cmd
Package config defines the config/config.yml configuration model.
Package config defines the config/config.yml configuration model.
Package flatstack provides the runner embedding API with an opt-in flat bytecode backend.
Package flatstack provides the runner embedding API with an opt-in flat bytecode backend.
engine
Package engine compiles model AST programs into flat bytecode and executes them against a host-provided PHP semantics bridge.
Package engine compiles model AST programs into flat bytecode and executes them against a host-provided PHP semantics bridge.
Package formatter pretty-prints phpscript ASTs in a gofmt-like style: hard tabs, canonical `function` keywords, parentheses on control structures, semicolons, collapsed blank lines, and a trailing newline.
Package formatter pretty-prints phpscript ASTs in a gofmt-like style: hard tabs, canonical `function` keywords, parentheses on control structures, semicolons, collapsed blank lines, and a trailing newline.
Package list builds a markdown inventory of PHP routes, files and classes.
Package list builds a markdown inventory of PHP routes, files and classes.
Package model holds the shared data structures (AST, runtime values, class metadata) used by both the parser and the runner packages.
Package model holds the shared data structures (AST, runtime values, class metadata) used by both the parser and the runner packages.
Package parser turns PHP source (the limited subset described in the project README) into the shared model AST consumed by the runner.
Package parser turns PHP source (the limited subset described in the project README) into the shared model AST consumed by the runner.
Package route scans a PHP source tree of .php files and registers Go standard library routes for annotated PHP endpoints on a standard library mux router.
Package route scans a PHP source tree of .php files and registers Go standard library routes for annotated PHP endpoints on a standard library mux router.
Package startup runs PHP files annotated with @startup during service startup.
Package startup runs PHP files annotated with @startup during service startup.
Package stdlib provides the forwarded "bring your own standard library" shims (the README's register_function mechanism).
Package stdlib provides the forwarded "bring your own standard library" shims (the README's register_function mechanism).
ps
status
Package status provides request tracing and HTTP server status pages.
Package status provides request tracing and HTTP server status pages.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL