go-php icon indicating copy to clipboard operation
go-php copied to clipboard

Continue running the go program after exit() in PHP

Open thekid opened this issue 7 years ago • 1 comments

Currently, if a PHP script calls exit(), not only does the script terminate, but also the GO binary running it - see #31. This pull request changes this in a backwards-compatible way* such that calls to Exec() and Eval() will return an error which can be checked for.

Example

val, err := context.Eval(script);

if err != nil {
    if exit, ok := err.(*php.ExitError); ok {
        fmt.Printf("PHP exited with exit status %d\n", exit.Status)
    } else {
        fmt.Printf("Could not execute script %s: %v", script, err)
    }
}

*: ...instead of changing the return types, or introducing any global state in context, or adding new methods. The API is modeled a bit after os/exec

thekid avatar Oct 01 '18 21:10 thekid

Apologies for the delay in responding to these PRs, and thanks for doing the work. Looking now.

deuill avatar Oct 07 '18 12:10 deuill