Status: Beta

The @now/php builder allows you to use any .php file.

Note: This builder will only include one PHP source file per Lambda. In the future, it will automatically include its dependencies via static analysis.

When to use it

Whenever you want to use PHP.

How to use it

Define a .php file:

<?php phpinfo(); ?>

And a now.json like:

{
  "version": 2,
  "builds": [{ "src": "*.php", "use": "@now/php" }]
}

After running now, you'll get a URL like this: https://php-deployment-7z9gyzb8j.now.sh/

The example deployment above is open-source and you can view the code for it here: https://php-deployment-7z9gyzb8j.now.sh/_src

Technical Details

Entrypoint

The entrypoint file must be a .php source file.

Global variables

All standard PHP variables like $_GET, $_POST are supported, with the exception of:

  • $_SESSION
  • $_FILES

Version

PHP 7.1.x is implemented via the go-php package and bundled as a Go binary.

Maximum Lambda Bundle Size

To help keep cold boot times low, the maximum output bundle size for a PHP lambda is, by default, 10mb.

This limit is extendable up to 50mb.

Example maxLambdaSize configuration:
{
  "builds": [
    { "src": "*.php", "use": "@now/php", "config": { "maxLambdaSize": "15mb" } }
  ]
}