config

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package config defines the config/config.yml configuration model.

Index

Constants

View Source
const VirtualHostConfigFile = "phpscript.yml"

VirtualHostConfigFile is the file in an application root that configures the virtual host rooted there.

Variables

View Source
var DefaultRuntimeConfig []byte

Functions

This section is empty.

Types

type Config

type Config struct {
	Runner    runner.Options `yaml:"runner"`
	Flatstack Flatstack      `yaml:"flatstack"`
	Routes    Routes         `yaml:"routes"`
	Server    Server         `yaml:"server"`
	Telemetry Telemetry      `yaml:"telemetry"`
	Env       []string       `yaml:"env"`

	// DocumentRoot is the directory beneath the application root that is
	// served over HTTP. It is "public" and almost never worth setting; it
	// exists for a site whose tree already names that directory something
	// else.
	DocumentRoot string `yaml:"document_root"`

	// VirtualHost is the list of sites this server routes by domain. Each
	// entry names an application root whose phpscript.yml is the
	// configuration that site runs under.
	VirtualHost []VirtualHost `yaml:"virtualhost"`
}

Config configures phpscript runtimes and HTTP modules.

func New

func New() Config

New returns the default configuration, which is config/config.yml as it is compiled into the binary. Defaults live in that file and nowhere else, so a file passed with -f is read on top of it and only has to name what it changes.

func NewTestConfig added in v0.3.0

func NewTestConfig() Config

NewTestConfig returns the default configuration with the parts a test has no use for turned off: a port picked by the kernel, no lifecycle logging, and no recorder, so parallel tests neither collide on a port nor record into each other.

func (Config) PlatformOptions added in v0.3.0

func (c Config) PlatformOptions() (*platform.Options, error)

PlatformOptions returns the platform options `phpscript server` runs under.

There is one recorder and the platform owns it: given these options it builds the tracer, wraps every module in the tracing middleware and mounts the debug front end under Telemetry.Path. phpscript registers no recorder of its own. It observes the interpreter onto the trace that middleware started, so interpreter spans show up on the same front end as the request that caused them.

func (Config) ValidateVirtualHosts added in v0.3.1

func (c Config) ValidateVirtualHosts() error

ValidateVirtualHosts checks the whole list before any site is built, so a bad entry fails the server rather than one request. Every entry is loaded here, because the document root and the telemetry block two of the checks need come from the site's phpscript.yml and not from the entry.

type Flatstack

type Flatstack struct {
	Enabled bool `yaml:"enabled"`
}

Flatstack selects the flat bytecode runtime when enabled.

type Routes

type Routes struct {
	Enabled bool `yaml:"enabled"`
}

Routes controls loading of annotated PHP routes by HTTP servers.

type Server added in v0.3.0

type Server struct {
	// Addr is the address the HTTP server listens on.
	Addr string `yaml:"addr"`

	// Quiet turns down platform lifecycle logging.
	Quiet bool `yaml:"quiet"`

	// Modules limits which platform modules load, by name. An empty list
	// loads all of them.
	Modules []string `yaml:"modules"`
}

Server is the YAML spelling of platform.Options: everything a configuration file gets to say about the platform `phpscript server` runs on. The options the platform takes from the process rather than from a file, such as the config filesystem a composed service embeds, are not part of it, and neither is the recorder: that one is the top level telemetry block, applied by Config.PlatformOptions.

func (Server) Options added in v0.3.0

func (s Server) Options() *platform.Options

Options returns the platform options this block describes, with no recorder configured. Callers want Config.PlatformOptions, which adds one.

type Telemetry added in v0.3.0

type Telemetry struct {
	telemetry.Options `yaml:",inline"`
	Driver            string `yaml:"driver"`
	StoragePath       string `yaml:"storage_path"`
}

Telemetry is oida options plus optional durable storage.

func (Telemetry) Resolved added in v0.3.0

func (t Telemetry) Resolved() (telemetry.Options, error)

Resolved returns oida options with storage applied.

type VirtualHost added in v0.3.1

type VirtualHost struct {
	// Domain is the Host header this entry answers for.
	Domain string `yaml:"domain"`

	// Aliases are further Host headers reaching the same site. They are the
	// same site, not copies of it: one application root, one configuration,
	// one set of connections and one recorder, no matter which name a
	// request arrived under. The usual case is a bare domain and its www
	// form.
	Aliases []string `yaml:"aliases"`

	// Root is the application root, the directory holding the site's
	// phpscript.yml.
	Root string `yaml:"root"`

	// DocumentRoot is the directory under Root served over HTTP. It defaults
	// to public and rarely needs setting: it is here for a site whose tree
	// already names that directory something else, not a field an operator is
	// expected to fill in.
	DocumentRoot string `yaml:"document_root"`
}

VirtualHost routes a set of domains to an application root. The operator owns these fields; everything else about the site comes from the phpscript.yml in Root, which the site's own author writes.

func (VirtualHost) Domains added in v0.3.1

func (v VirtualHost) Domains() []string

Domains returns every name this entry answers for, the domain first.

func (VirtualHost) Load added in v0.3.1

func (v VirtualHost) Load(base Config) (Config, error)

Load reads Root/phpscript.yml over base and returns the configuration the virtual host runs under, with the document root resolved.

func (VirtualHost) Normalize added in v0.3.1

func (v VirtualHost) Normalize() VirtualHost

Normalize lowercases every name the entry answers for and trims a trailing dot, so a Host header compares equal to a configured domain.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL