phpstart

package module
v0.5.24 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: Apache-2.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

PHP Start Cloud Native Buildpack

gcr.io/paketo-buildpacks/php-start

A Cloud Native Buildpack for running HTTPD, Nginx, and FPM start commands for PHP apps.

Behavior

This buildpack will always participate if its requirements are met. In the HTTPD server case requires php, php-fpm optionally, httpd, and php-httpd-config. In the Nginx case, it will require nginx and php-nginx-config instead of httpd and php-httpd-config.

In either the HTTPD server or Nginx case, this buildpack will require composer-packages when a composer.json file is available.

When this buildpack runs, the PHP_HTTPD_PATH OR the PHP_NGINX_PATH environment variable must be set by another buildpack in conjunction with PHP_FPM_PATH. This is because both the HTTPD and Nginx web servers will require FPM to serve PHP apps. The build will fail if both PHP_HTTPD_PATH and PHP_NGINX_PATH are set or both unset, as well as if the PHP_FPM_PATH environment variable is not set. These requirements will be met when used in conjunction with the other buildpacks in the Paketo PHP language family. Because of this, the usage of this buildpack is fairly tightly coupled to other buildpacks in the PHP language family.

Requirement Build Launch
php x
composer-packages x
php-fpm x x
httpd or nginx x
httpd-config or nginx-config x x

It will set the default start command to something that looks like:

procmgr-binary /layers/paketo-buildpacks_php-start/php-start/procs.yml

The procmgr-binary is a process manager that will run multiple start commands on the container. This is done to allow for FPM to run on the container alongside the web server. The procs.yml file it runs with contains the commands and arguments for both php-fpm and the web-server.

When the buildpack runs, you will see in the logs what processes are added to procs.yml.

Live Reload

Both httpd and nginx automatically reload changed files, so applications built by this buildpack implicitly support live reloading of served files.

This buildpack adds explicit live reload support for httpd and nginx configuration files at the following locations:

  • http: <app-directory>/.httpd.conf.d/
  • nginx: <app-directory>/.nginx.conf.d/

See the following integration test files for examples of both application code live reload and configuration live reload.

  • integration/httpd_reload_test.go
  • integration/nginx_reload_test.go

Integration

This CNB writes a start command, so there's currently no scenario we can imagine that you would need to require it as dependency.

Usage

To package this buildpack for consumption:

$ ./scripts/package.sh --version <version-number>

This will create a buildpackage.cnb file under the build directory which you can use to build your app as follows:

pack build <app-name> \
  --path <path-to-app> \
  --buildpack build/buildpackage.cnb

Run Tests

To run all unit tests, run:

./scripts/unit.sh

To run all integration tests, run:

/scripts/integration.sh

Debug Logs

For extra debug logs from the image build process, set the $BP_LOG_LEVEL environment variable to DEBUG at build-time (ex. pack build my-app --env BP_LOG_LEVEL=DEBUG or through a project.toml file.

Documentation

Index

Constants

View Source
const (
	PhpHttpdConfig = "php-httpd-config"
	PhpNginxConfig = "php-nginx-config"
	Nginx          = "nginx"
	Httpd          = "httpd"
	Php            = "php"
	PhpFpm         = "php-fpm"
	Watchexec      = "watchexec"
)

Variables

This section is empty.

Functions

func Build

func Build(procs ProcMgr, logger scribe.Emitter, reloader Reloader) packit.BuildFunc

Build will return a packit.BuildFunc that will be invoked during the build phase of the buildpack lifecycle.

It will create a layer dedicated to storing a process manager and YAML file of processes to run, since there are multiple process that could be run. The layer is available at and launch-time, and its contents are used in the image launch process.

func Detect

func Detect(reloader Reloader) packit.DetectFunc

Detect will return a packit.DetectFunc that will be invoked during the detect phase of the buildpack lifecycle.

This buildpack has two requirement groups: One for HTTPD in which the following are required at launch time: - "php" - "php-fpm" - "httpd" - "httpd-config" Another for NGINX in which the following are required at launch time: - "php" - "php-fpm" - "nginx" - "nginx-config"

Additionally, this buildpack will require 'composer-packages' when a composer.json is found.

This buildpack will always detect.

Types

type BuildPlanMetadata

type BuildPlanMetadata struct {

	// Launch flag requests the given requirement be made available during the
	// launch phase of the buildpack lifecycle.
	Launch bool `toml:"launch"`

	// Build flag requests the given requirement be made available during the
	// build phase of the buildpack lifecycle.
	Build bool `toml:"build"`
}

BuildPlanMetadata is the buildpack specific data included in build plan requirements.

type Proc

type Proc struct {
	Command string
	Args    []string
}

Proc is a single process to run

func NewProc

func NewProc(command string, args []string) Proc

type ProcMgr

type ProcMgr interface {
	Add(name string, proc Proc)
	WriteFile(path string) error
}

ProcMgr manages all processes that the build phase may need to run by adding them to a procs.yml file for execution at launch time.

type Procs

type Procs struct {
	Processes map[string]Proc
}

Procs is the existing list of process names and commands to run

func NewProcs

func NewProcs() Procs

func ReadProcs

func ReadProcs(path string) (Procs, error)

ReadProcs is a utility function that given a path to `procs.yml`, will unmarshall it into a Procs process list.

func (Procs) Add

func (procs Procs) Add(procName string, newProc Proc)

Add takes a process and a name, and adds it to the process list.

func (Procs) WriteFile

func (procs Procs) WriteFile(path string) error

WriteFile writes a Procs process list into YAML onto the given path

type Reloader added in v0.3.0

type Reloader libreload.Reloader

Directories

Path Synopsis
cmd
procmgr-binary command

Jump to

Keyboard shortcuts

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