mirror of
https://github.com/dunglas/frankenphp.git
synced 2025-12-24 13:38:11 +08:00
* feat: mercure_publish() PHP function to dispatch Mercure updates * fix stubs for old versions * review * cleanup and fixes
36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
// Package caddy provides a PHP module for the Caddy web server.
|
|
// FrankenPHP embeds the PHP interpreter directly in Caddy, giving it the ability to run your PHP scripts directly.
|
|
// No PHP FPM required!
|
|
package caddy
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/caddyserver/caddy/v2"
|
|
"github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile"
|
|
)
|
|
|
|
const (
|
|
defaultDocumentRoot = "public"
|
|
defaultWatchPattern = "./**/*.{php,yaml,yml,twig,env}"
|
|
)
|
|
|
|
func init() {
|
|
caddy.RegisterModule(FrankenPHPApp{})
|
|
caddy.RegisterModule(FrankenPHPModule{})
|
|
caddy.RegisterModule(FrankenPHPAdmin{})
|
|
|
|
httpcaddyfile.RegisterGlobalOption("frankenphp", parseGlobalOption)
|
|
|
|
httpcaddyfile.RegisterHandlerDirective("php", parseCaddyfile)
|
|
httpcaddyfile.RegisterDirectiveOrder("php", "before", "file_server")
|
|
|
|
httpcaddyfile.RegisterDirective("php_server", parsePhpServer)
|
|
httpcaddyfile.RegisterDirectiveOrder("php_server", "before", "file_server")
|
|
}
|
|
|
|
// wrongSubDirectiveError returns a nice error message.
|
|
func wrongSubDirectiveError(module string, allowedDirectives string, wrongValue string) error {
|
|
return fmt.Errorf("unknown %q subdirective: %s (allowed directives are: %s)", module, wrongValue, allowedDirectives)
|
|
}
|