MCPcopy Index your code
hub / github.com/php/frankenphp / Provision

Method Provision

caddy/module.go:65–192  ·  view source on GitHub ↗

Provision sets up the module.

(ctx caddy.Context)

Source from the content-addressed store, hash-verified

63
64// Provision sets up the module.
65func (f *FrankenPHPModule) Provision(ctx caddy.Context) error {
66 f.logger = ctx.Slogger()
67 app, err := ctx.App("frankenphp")
68 if err != nil {
69 return err
70 }
71 fapp, ok := app.(*FrankenPHPApp)
72 if !ok {
73 return fmt.Errorf(`expected ctx.App("frankenphp") to return *FrankenPHPApp, got %T`, app)
74 }
75 if fapp == nil {
76 return fmt.Errorf(`expected ctx.App("frankenphp") to return *FrankenPHPApp, got nil`)
77 }
78
79 f.assignMercureHub(ctx)
80
81 loggerOpt := frankenphp.WithRequestLogger(f.logger)
82 for i, wc := range f.Workers {
83 // make the file path absolute from the public directory
84 // this can only be done if the root is defined inside php_server
85 if !filepath.IsAbs(wc.FileName) && f.Root != "" {
86 wc.FileName = filepath.Join(f.Root, wc.FileName)
87 }
88
89 // Inherit environment variables from the parent php_server directive
90 if f.Env != nil {
91 wc.inheritEnv(f.Env)
92 }
93
94 wc.requestOptions = append(wc.requestOptions, loggerOpt)
95 f.Workers[i] = wc
96 }
97
98 workers, err := fapp.addModuleWorkers(f.Workers...)
99 if err != nil {
100 return err
101 }
102 f.Workers = workers
103
104 if f.Root == "" {
105 if frankenphp.EmbeddedAppPath == "" {
106 f.Root = "{http.vars.root}"
107 } else {
108 f.Root = filepath.Join(frankenphp.EmbeddedAppPath, defaultDocumentRoot)
109
110 f.ResolveRootSymlink = new(false)
111 }
112 } else if frankenphp.EmbeddedAppPath != "" && filepath.IsLocal(f.Root) {
113 f.Root = filepath.Join(frankenphp.EmbeddedAppPath, f.Root)
114 }
115
116 if len(f.SplitPath) == 0 {
117 f.SplitPath = []string{".php"}
118 }
119
120 opt, err := frankenphp.WithRequestSplitPath(f.SplitPath)
121 if err != nil {
122 return fmt.Errorf("invalid split_path: %w", err)

Callers

nothing calls this directly

Calls 11

assignMercureHubMethod · 0.95
configureHotReloadMethod · 0.95
WithRequestLoggerFunction · 0.92
WithRequestSplitPathFunction · 0.92
FastAbsFunction · 0.92
PrepareEnvFunction · 0.92
WithRequestPreparedEnvFunction · 0.92
needReplacementFunction · 0.85
inheritEnvMethod · 0.80
addModuleWorkersMethod · 0.80

Tested by

no test coverage detected