Migrating a PHP application to AWS Lambda with Bref
A conventional PHP application usually assumes a long-lived web server, a writable document root and extensions such as PDO already installed. Those assumptions do not disappear when code is copied into AWS Lambda. Bref supplies a PHP runtime and a bridge to Lambda’s managed execution environment, letting a Composer application run behind API Gateway, a function URL or an application load balancer. It reduces server patching, but it remains an architecture change rather than a deployment shortcut.
For an Australian team running a booking platform, customer portal or Laravel storefront, the work begins by separating synchronous requests from background jobs. A staged move can start with a low-risk endpoint, measure cold starts and database connections, and retain a rollback path. The goal is to preserve the controls systems administrators expect: least-privilege access, repeatable infrastructure, useful logs and a rehearsed cutover.
Why Bref suits Lambda
Bref packages the PHP application, Composer dependencies and runtime files into a Lambda deployment. A function can use a web handler for HTTP requests, while Bref manages PHP-FPM inside the execution environment. Existing framework routing, service classes and externally stored sessions can remain in place. This is useful for tested PHP applications that need elastic scaling and less operating-system maintenance.
The boundary matters. Lambda provides a temporary filesystem and limited execution time, not the persistent disk, resident worker or operating-system configuration of a traditional VPS. Long-running consumers, image processing and scheduled scripts should become separate functions with their own timeouts and concurrency settings. Move writable uploads to S3 and local cache data to Redis or DynamoDB. Bref removes packaging friction, not the need to redesign stateful assumptions.
Preparing the application
Inventory the PHP version, extensions, Composer packages, environment variables, cron entries and outbound calls. Run the test suite, then exercise the same code through Bref’s local tooling so differences in headers, request bodies, uploads and error handling appear before deployment. Remove assumptions about permanent files, local locks and writable application directories. Confirm that database drivers, XML and mbstring are available in the selected runtime, and update packages that rely on removed system libraries.
Package the application as a reproducible artifact. Give each Lambda function an explicit handler, pinned runtime, memory setting, timeout and environment variables pointing to managed services. Keep secrets out of code and deployment files, retrieving them from AWS Secrets Manager or Parameter Store at runtime. Use separate development, staging and production accounts or stacks, and promote the same tested artifact through the pipeline. This prevents a local PHP install from hiding a missing extension or an incorrectly scoped IAM policy.
Operational readiness belongs in the same checklist. If technicians carry company iPhones, the recovering a powered-off iPhone process is a useful support-runbook reference, while application access should be revoked centrally when a device is lost. For the migration, verify password resets, support impersonation, audit trails and emergency access without the familiar web server.
Infrastructure, events, and observability
For HTTP traffic, API Gateway is a common front door; an application load balancer or Lambda function URL may better suit an existing domain and routing model. Preserve required request limits, binary support, WebSocket behaviour and custom headers. Test redirects, cookies, validation errors and exception responses, because a generic gateway error can conceal an application fault.
Match background work to its semantics: SQS for queue-driven jobs, EventBridge for scheduled rules, and SNS or EventBridge for fan-out. Each worker needs a bounded batch, retry policy and dead-letter queue. Schedule in UTC and display Australian times carefully because Sydney and Melbourne change clocks while Brisbane does not. A Lambda connected to Aurora or RDS in a VPC also brings DNS, subnet, routing and NAT considerations, plus strict connection-pool limits.
Use CloudWatch logs, custom metrics and alarms for invocations, errors, duration, throttles, queue age and database latency. Put a correlation identifier in structured logs, while redacting tokens, card details and personal information. Place workloads in the region that best serves Australian users: Sydney, ap-southeast-2, and Melbourne, ap-southeast-4, are the usual starting points, with Brisbane commonly closest to Sydney. Test latency from major cities and confirm residency, backup and support-access terms for regulated data.
Security, data, and Australian requirements
Lambda removes the need to patch a web-server operating system, but it does not remove application-security work. Give each function a dedicated execution role with only required permissions, restrict API access, and encrypt data in transit and at rest. Use TLS, sensible authentication, rate limiting and a WAF where appropriate. Pin dependencies, scan packages, review Lambda layers and update them regularly. Place workforce access behind identity controls, and record configuration changes in CloudTrail.
For an Australian organisation handling personal information, map data flows before changing hosting. Where the Privacy Act 1988 and Australian Privacy Principles apply, the organisation may need a documented privacy policy, purpose limitation, access controls, correction and deletion processes, and a defensible breach response. If the Notifiable Data Breaches scheme applies, the legal threshold can require notification to affected people and the Office of the Australian Information Commissioner. Marketing email and SMS also bring Spam Act 2003 and Do Not Call Register obligations. AWS supplies technical controls; legal responsibility stays with the organisation using the service.
The same planning discipline applies to adjacent systems. My on-premises Exchange migration guide shows how a staged infrastructure move can preserve identity, coexistence and rollback instead of relying on one cutover weekend. For PHP, the equivalent checkpoints include authentication, file access, scheduled jobs, webhooks, email delivery and reporting. Assign an owner to each integration and document its behaviour when AWS, a database or a third-party API is unavailable.
Practical recommendations for a controlled launch
Treat production migration as a rehearsable release, not a last-minute file copy. Start with a read-only or low-impact route, keep the legacy environment available for comparison, and define abort thresholds for error rate, latency, queue backlog and support volume. Automate infrastructure and database changes, then use a game day to exercise failures as well as the happy path. The following recommendations keep the change observable and reversible:
- Record PHP versions, extensions, dependencies, cron jobs, scheduled tasks and outbound integrations before changing the runtime.
- Run existing tests and Bref local checks covering authentication, uploads, redirects, errors and background jobs.
- Store sessions, uploads and caches in managed services rather than relying on Lambda’s filesystem.
- Keep execution roles narrow, load secrets at runtime, encrypt sensitive data and scan dependencies.
- Deploy separate environments and promote the same immutable, tested artifact.
- Monitor latency, cold starts, throttles, queue age, database connections and business failures.
- Rehearse rollback, database recovery, secret rotation and incident communication before traffic moves.
After launch, compare availability and response times with the legacy server, then review memory, concurrency and cost. More memory can reduce CPU time; provisioned concurrency may help a latency-sensitive endpoint but adds expense. Check NAT charges, log retention and storage growth, remove unused resources, and assign owners to follow-up actions. That evidence makes the next phase safer and easier to justify.
Australian SMEs running PHP shops, membership portals and internal tools can reduce undifferentiated server administration while keeping a familiar programming model. The gain comes from predictable deployment, observability and recovery, not merely replacing a VPS with a function.
For an independent architecture review or migration-planning discussion, my Karl Katzke’s resume provides relevant cloud migration, infrastructure-planning and systems-administration experience. Select one representative workflow, document its dependencies, and test it in a staging stack before shifting customer traffic.
Karl Katzke