mirror of
https://github.com/dunglas/frankenphp
synced 2024-10-16 09:08:22 +00:00
docs: add an exemple
This commit is contained in:
parent
9761090c06
commit
8c87075db8
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/http/cookiejar"
|
||||
"net/http/httptest"
|
||||
@ -304,3 +305,17 @@ func testPhpInfo(t *testing.T, scriptName string) {
|
||||
assert.Contains(t, string(body), "frankenphp")
|
||||
}
|
||||
}
|
||||
|
||||
func Example() {
|
||||
frankenphp.Startup()
|
||||
defer frankenphp.Shutdown()
|
||||
|
||||
phpHandler := func(w http.ResponseWriter, req *http.Request) {
|
||||
if err := frankenphp.ExecuteScript(w, req); err != nil {
|
||||
log.Print(fmt.Errorf("error executing PHP script: %w", err))
|
||||
}
|
||||
}
|
||||
|
||||
http.HandleFunc("/", phpHandler)
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user