phpscript - an inter-operable PHP syntax VM written in Go (no CGO). (github.com)
from sanitation@lemmy.today to golang@programming.dev on 20 Jun 21:54
https://lemmy.today/post/55155046

This project is an extensive experiment that got out of hand. It aims to provide a restricted PHP runtime to interface with Go code, as well as run more extensive PHP code like a full blown PHP template engine with eval and what not. It provides implicit context and error return handling, triggering an exception if an error occurs in the request. The exception can be caught with try/catch, or be passed into the error handler inside the go runner.

Main benefits are:

The PHP runtime in this case is written in Go, pure Go, and doesn’t rely on CGO to provide functionality like FrankenPHP does. The changes to .php files are immediately visible without a server restart.

It’s all experimental so if you’re interested in this, there may be quite a few feature gaps to maturity. That said, you could use what’s implemented and extend it with your own APIs where the odd standard library function is missing. You may want to consider this a portable interpreter as well, as you could delivery it as a static binary, further reducing PHP runtime environment requirements.

I worked with the plugin standard library package extensively in the past, and I was always missing an option where the runtime would be severely restricted, and you could provide APIs in Go directly. Maybe it’s the power of Go, it’s way easier to build a PHP runtime than it is to get a decent SSR CMS website under type safety and similar restrictions (no globals, no shared state).

Current goals:

Optimization of the pre-execution steps, exposing a database client to the PHP code to directly write SQL queries, figuring out a routing system that takes nice URLs into account, more test coverage with the template engine. Maybe write a nice /admin dashboard without drama

#golang

threaded - newest

kibblebits@quokk.au on 20 Jun 22:04 collapse

My god why