GithubHelp home page GithubHelp logo

php-builtin-server's Introduction

Paketo Buildpack for PHP Built-in Web Server Cloud Native

The PHP Built-in Web Server Buildpack sets up and runs PHP's built-in web server to support PHP applications

The buildpack is published for consumption at gcr.io/paketo-buildpacks/php-builtin-server and paketo-buildpacks/php-builtin-server.

Behavior

This buildpack is the default web-server in the PHP buildpack, and it will pass detection as long as there is a *.php file found in the web directory. More information about how to set the web directory path is available in the "Configuration" section below. Users can declare an explicit intention to use the built-in server if the BP_PHP_SERVER environment variable is set to php-server at build-time this buildpack will participate, however since it is the default web server, the buildpack will also participate if the environment variable isn't set at all.

The buildpack will do the following:

  • At run time:
    • Contribute a start command for the PHP built-in webserver

This buildpack requires php at launch time, and will also optionally require composer-packages at launch-time if the application contains a composer.json file or the $COMPOSER environment variable is set.

Configuration

BP_PHP_WEB_DIR

The web directory or document root can be configured via the BP_PHP_WEB_DIR environment variable as a relative path under the app directory. Set the environment variables at build time either directly or through a project.toml file.

pack build flag

pack build my-app --env BP_PHP_WEB_DIR="htdocs"

In a project.toml

[build]
  [[build.env]]
    name = 'BP_PHP_WEB_DIR'
    value = 'htdocs'

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> -p <path-to-app> -b build/buildpackage.cnb -b <other-buildpacks..>

To run the unit and integration tests for this buildpack:

$ ./scripts/unit.sh && ./scripts/integration.sh

php-builtin-server's People

Contributors

dependabot[bot] avatar foresteckhardt avatar joshuatcasey avatar paketo-bot avatar robdimsdale avatar sophiewigmore avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

joshuatcasey

php-builtin-server's Issues

Restructure buildpack: Create php-builtin-server buildpack

Context

Per PHP RFC 0001 we are restructuring the PHP language family of buildpacks to make them more modular, up-to-date, and as a result, maintainable.

Currently, the PHP Web buildpack is responsible for configuring and running PHP applications across built-in PHP servers, HTTPD, NGINX, as well as supporting FPM process managers. The goal of this issue is to separate the concerns within PHP Web into individual buildpacks.

Issue

This issue is to add a new buildpack, named php-builtin-server, which will be responsible for setting up PHP's built-in web server to serve PHP applications.

Logic to support the PHP built-in webserver currently lives within the PHP Web buildpack and should be moved into this new buildpack.

  • API: The buildpack should provide none and require php at launch-time.

  • The buildpack will be responsible for setting a start command of type web for the built-in web server. It is the default web server. Check out how this was accomplished in the PHP Web buildpack.

  • Packit: This buildpack should be written using the packit library.

  • Buildpack API Version: This buildpack should be written using Buildpack API 0.7

  • README: Make sure a README is added that conveys context about the buildpack in a manner consistent with other Paketo buildpacks.

This issue can be transferred to the appropriate repository (paketo-buildpacks/php-builtin-server), once it has been created.

Acceptance

  1. I can successfully build a PHP app that uses a built-in web-server such as this simple built-in PHP server app, with PHP Dist, and the new PHP Builtin Server buildpack, and see logs that shows the app is run with the PHP Web Server (command like php -S 0.0.0.0:$PORT..), and I can curl the app and see SUCCESS.

libxml2 not installed

The Buildpack is not installing libxml2 which is needed for PHP to run.

Expected Behavior

Shall not the PHP Buildpack install libxml2 natively? I am new to using Buildpack so I may be missing something :)

Current Behavior

$ cf push php-builtin
Pushing app php-builtin to org tutorial-org / space tutorial-space as cf-admin...
Packaging files to upload...
Uploading files...
 1.57 KiB / 1.57 KiB [=========================================================================================================================] 100.00% 1s

Waiting for API to complete processing files...

Staging app and tracing logs...
BuildFailed: Check build log output
FAILED
$ cf logs php-builtin --recent
Retrieving logs for app php-builtin in org tutorial-org / space tutorial-space as cf-admin...

   1970-01-01T00:00:00.00+0000 [STG/] OUT
   2023-07-31T18:40:37.39+0000 [APP/] OUT php: error while loading shared libraries: libxml2.so.2: cannot open shared object file: No such file or directory

Steps to Reproduce

git clone https://github.com/paketo-buildpacks/samples/tree/main/php/builtin-server
cf push php-builtin
cf logs php-builtin --recent

Motivations

I am trying to push a PHP app using CloudFoundry Korifi.

Enable Debug Logging

With the merging of RFC 27 buildpacks should respect the BP_LOG_LEVEL environment variable and allow for debugging logging.

A good example of how to minimally implement this feature can be found in Go Build.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.