How to run PHP code from within a Go application? #1022
Replies: 1 comment 2 replies
-
Hey hey, I'm using this feature on an experimental runtime I've been working on for the last couple of years. It's nowhere near finished or even production ready; but you can take a look at the code: https://github.com/bottledcode/durable-php/blob/v2/cli/glue/glue.go#L147-L209 I went with creating a custom "request" and using a custom ResponseWriter to intercept and log output.
At work, we use this same method of custom requests to read from a queue (in go), transform it to a request, and have php process the job. When we return to go, the output may contain other messages to send. It's like 300 lines of code in go, and there would be thousands of lines in php with lots of headaches to manage processes, memory, etc. Sure, there are opinionated php libraries to make it easier, but you can't beat 300 lines of non-opinionated code. |
Beta Was this translation helpful? Give feedback.
-
My application is primarily written in PHP, but I am starting to add some background services written in Go. Is there a way to use Frankenphp's innovations to execute existing PHP code/scripts from within the Go application?
Is it with the ExecuteScriptCLI function? Can this essentially run an entire php application if the script you call bootstraps itself with require/include?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions