Coder Social home page Coder Social logo

php-memcached-session-handler's Introduction

Php Memcached Session Handler Cloud Native Buildpack

A Cloud Native Buildpack for configuring a Memcached session handler in PHP apps.

The buildpack generates an .ini configuration snippet to allow for connecting to an external Memcached server as a session handler. The servers, username, and password are configurable via service bindings.

Integration

The PHP Memcached Session Handler CNB provides nothing, and only requires php at launch time. It detects on the presence of a service binding of type php-memcached-session.

Service Binding Configuration

As mentioned above, the buildpack participates in the build if the user provides a service binding of type php-memcached-session.

The build command will look like:

pack build myapp --env SERVICE_BINDING_ROOT=/bindings --volume <absolute-path-to-binding>:/bindings/php-memcached-session

Inside of the binding itself, the following configuration can be set:

  • servers (Default 127.0.0.1): Memcached instance IP address
  • username (Default ""): Memcached instance username, if there is one
  • password (Default ""): Memcached instance password, if there is one

The configurations from the service binding are parsed and used to create a php-memcached.ini file with session configurations. The php-memcached.ini file is available in the PHP Memcached Session Handler buildpack layer on the image, and its path is appended to the PHP_INI_SCAN_DIR for usage when the app starts up.

Usage

To package this buildpack for consumption:

$ ./scripts/package.sh

This builds the buildpack's Go source using GOOS=linux by default. You can supply another value as the first argument to package.sh.

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.

php-memcached-session-handler's People

Contributors

dependabot[bot] avatar dmikusa avatar paketo-bot avatar robdimsdale avatar sophiewigmore avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

php-memcached-session-handler's Issues

Restructure buildpack: Create php-memcached-session-handler 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 setting up session handlers. 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-memcached-session-handler, which will be responsible for configuring a given memcached service instance as a PHP session handler.

Logic to support memcache service configuration 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.

  • Settings for the handler should be provided via a binding. Check out how this was accomplished in the PHP Web buildpack, although note we will be using the Service Binding Specification for Kubernetes

  • This buildpack should detect the presence of a memcached-sessions service binding and then use the service binding contents to set up the memcache session itself via a php.ini file. As it stands now, the memcache extension is included in the PHP distribution installed by PHP Dist buildpack.

  • This buildpack must append to the PHP_INI_SCAN_DIR environment variable to modify the search path so PHP will locate any .ini configuration files required by the handler to operate.

  • Direct processes: Use direct processes and exec.d where applicable (instead of indirect processes and profile.d)

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

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

  • Add a [[buildpack.licences]] section to the buildpack.toml.

  • 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-memcached-session-handler), once it has been created.

Acceptance

  1. I can successfully build a PHP app that uses a session handler such as the session-test fixture in PHP Web, with PHP Dist and the new PHP Memcached Session Handler buildpack. During the build, I can see logs that show the memcache session handler is being used. I can also run the container and curl the app and see Memcached Loaded: 1 and Session Handler: memcached.

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.