Documentation
¶
Overview ¶
Package config defines the config/config.yml configuration model.
Index ¶
Constants ¶
const VirtualHostConfigFile = "phpscript.yml"
VirtualHostConfigFile is the file in an application root that configures the virtual host rooted there.
Variables ¶
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"`
// Autoindex answers a directory that has no index page with a listing of
// what is in it, the way nginx's autoindex does. It is off, because
// publishing every file below the document root is a decision a site
// makes and not one it should arrive at by leaving an index.html out.
Autoindex bool `yaml:"autoindex"`
// 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
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
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.
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.
type VirtualHost ¶ added in v0.3.1
type VirtualHost struct {
// Domain is the Host headers this entry answers for, separated by
// spaces. Every name reaches the same site, not a copy 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, "example.com www.example.com".
//
// The first name is the site's own, the one it is reported under.
Domain string `yaml:"domain"`
// 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, in the order Domain lists them, lowercased and without a trailing dot so a Host header compares equal to a configured name.
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) Name ¶ added in v0.3.3
func (v VirtualHost) Name() string
Name is the first name the entry lists. It is what the site is reported under in errors and in the names of the modules it registers, so that a site answering to several names is still one identifiable site.
func (VirtualHost) Normalize ¶ added in v0.3.1
func (v VirtualHost) Normalize() VirtualHost
Normalize rewrites Domain as the list Domains returns, so an entry carries the names a Host header is compared against rather than the spelling the operator used.