mirror of
https://github.com/dunglas/frankenphp
synced 2024-10-16 17:14:59 +00:00
7d81fa51fe
* refactor: better memory management * wip * tmp * introduce a go-like api * upgraded to PHP 8.2 * Fix thread safety issues * fix tests * wip * refactor worker * worker prototype * fix populate env * session * improve tests * fix Caddy tests * refactor
45 lines
881 B
Go
45 lines
881 B
Go
package caddy_test
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/caddyserver/caddy/v2/caddytest"
|
|
)
|
|
|
|
func TestPHP(t *testing.T) {
|
|
tester := caddytest.NewTester(t)
|
|
tester.InitServer(`
|
|
{
|
|
http_port 9080
|
|
https_port 9443
|
|
}
|
|
localhost:9080 {
|
|
route {
|
|
root * {env.PWD}/../testdata
|
|
# Add trailing slash for directory requests
|
|
@canonicalPath {
|
|
file {path}/index.php
|
|
not path */
|
|
}
|
|
redir @canonicalPath {path}/ 308
|
|
|
|
# If the requested file does not exist, try index files
|
|
@indexFiles file {
|
|
try_files {path} {path}/index.php index.php
|
|
split_path .php
|
|
}
|
|
rewrite @indexFiles {http.matchers.file.relative}
|
|
|
|
# Handle PHP files with FrankenPHP
|
|
@phpFiles path *.php
|
|
php @phpFiles
|
|
|
|
respond 404
|
|
}
|
|
}
|
|
`, "caddyfile")
|
|
|
|
tester.AssertGetResponse("http://localhost:9080", http.StatusOK, "I am by birth a Genevese")
|
|
}
|