This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
vercel-php is a PHP runtime for the Vercel platform enabling serverless PHP applications. It bundles PHP 8.3 with common extensions and supports multiple execution modes (built-in server, CGI, CLI).
make install # Install dependencies (npm install)
make build # Compile TypeScript to dist/ (npm run build)
make build-watch # Watch mode compilation (npm run watch)
make test # Run Jest test suite (npm run test)
make test-watch # Run tests in watch mode
make publish # Publish to npm (latest tag)
make canary # Publish to npm (canary tag)The package implements Vercel's BuildV3 specification, exporting:
version = 3- API versionbuild()- Main builder functionprepareCache()- Cache preparationshouldServe()- File serving decisions
- Download user files and PHP runtime (
@libphp/amazon-linux-2-v83) - Run
composer installifcomposer.jsonexists - Execute
composer run vercelscript if defined - Merge user
api/php.iniwith runtime defaults - Package everything into AWS Lambda function
- builtin.ts - PHP's built-in server (
php -S 0.0.0.0:3000), proxied via Node.js. Default mode. - cgi.ts - Spawns
php-cgiper request with CGI environment variables. Stateless. - cli.ts - Direct PHP CLI execution for simple scripts.
src/index.ts- Build entry point implementing BuildV3src/utils.ts- Build utilities (Composer, PHP config, file collection)src/launchers/helpers.ts- Request/response transformation between Vercel events and PHP
Key types: UserFiles, RuntimeFiles, Event, InvokedEvent, AwsRequest, AwsResponse, PhpInput, PhpOutput, CgiInput
- Logging uses 🐘 emoji prefix for console output
- Exit codes: 253-255 for critical child process errors, 1 for general errors
- User files are prefixed with
/user/in Lambda task root - TypeScript strict mode with
noImplicitAny,noUnusedLocals,noUnusedParameters - 2-space indentation for JS/TS/JSON/YAML/MD files
Tests are in test/spec/ with example projects in test/examples/. Jest timeout is 10 seconds.