Kokil Thapa - Professional Web Developer in Nepal
Freelancer Web Developer in Nepal with 15+ Years of Experience

Kokil Thapa is an experienced full-stack web developer focused on building fast, secure, and scalable web applications. He helps businesses and individuals create SEO-friendly, user-focused digital platforms designed for long-term growth.

Serverless PHP Options in 2026 Compared

By Kokil Thapa | Last reviewed: September 2026

Serverless PHP options in 2026 compared matter because traffic spikes and idle servers both cost money. Traditional VPS hosting with PHP-FPM still runs most production Laravel and WordPress sites I maintain. Yet event-driven APIs, webhooks, and bursty workloads can fit function-as-a-service or container-based serverless better. This guide compares the platforms that actually run PHP 8.3–8.5 in 2026, with real trade-offs on cold starts, database connections, and deployment workflows. If you are weighing Ubuntu server setup for PHP apps against pay-per-invocation billing, start here.

What counts as serverless PHP in 2026?

True serverless PHP means your code runs on a platform that scales to zero and bills per request or per CPU-second. You do not patch the OS or reload PHP-FPM yourself. In practice, PHP serverless always ships as a custom runtime or container because PHP was not a first-class FaaS language like Node.js or Python.

The four serious options in 2026 are:

  • AWS Lambda + Bref — PHP layers and custom runtimes for Lambda.
  • Laravel Vapor — managed Laravel deployment on top of Lambda, SQS, and RDS.
  • Google Cloud Run — Docker containers with automatic scaling, ideal for Symfony or Laravel Octane.
  • Azure Container Apps — similar container model with KEDA-based scaling.

Azure Functions and Google Cloud Functions offer limited or experimental PHP support. Most teams skip them and use containers instead. Platforms like Vercel and Netlify are not realistic PHP homes in 2026.

Serverless PHP Landscape 2026Function FaaSAWS Lambda + BrefLaravel VaporContainer ServerlessGoogle Cloud RunAzure Container AppsTraditional VPS (still default)Apache/Nginx + PHP-FPM 8.3–8.5Deployer 7, queues, cron, long sessions
Serverless PHP options in 2026 split into Lambda functions and auto-scaled containers versus traditional VPS hosting.

For background on the non-serverless baseline, see the Nginx vs Apache comparison for PHP sites. Most Laravel booking platforms I ship still run on VPS with queues and scheduled tasks.

How does AWS Lambda with Bref run PHP?

Bref packages PHP for AWS Lambda using custom runtimes and layers. You deploy a serverless.yml file via the Serverless Framework or SAM. Composer dependencies get bundled into the deployment artifact. PHP 8.3 and 8.4 runtimes are supported; verify 8.5 support in the Bref release notes before upgrading.

Minimal Bref handler example

# serverless.yml (excerpt)
service: my-api

provider:
  name: aws
  runtime: provided.al2
  region: ap-south-1

plugins:
  - ./vendor/bref/bref

functions:
  api:
    handler: public/index.php
    layers:
      - ${bref:layer.php-83}
      - ${bref:layer.php-83-fpm}
    events:
      - httpApi: '*'

The handler bootstraps your front controller. Laravel and Symfony both work, but boot time directly affects cold-start latency. Keep service providers lean. Use OPcache tuning guidance as a mental model—even on Lambda, opcache is pre-warmed inside the runtime layer.

What Bref handles well

  • API endpoints and webhook receivers (payment callbacks, SMS delivery reports).
  • Scheduled tasks via EventBridge instead of server cron.
  • Queue workers as separate Lambda functions consuming SQS messages.
  • Asset storage on S3 with CloudFront—no local filesystem.

Where Bref struggles

Cold starts on Lambda typically run 200 ms to 2 s for PHP, depending on memory and package size. A heavy Laravel 13 app with dozens of service providers pays a real penalty. Lambda max execution time is 15 minutes, but API Gateway times out at 29 seconds for HTTP APIs. Long exports belong on a queue worker function or Cloud Run instead.

Database connections are the other pain point. MySQL on RDS does not love hundreds of short-lived Lambda invocations opening fresh connections. Use RDS Proxy, or Aurora Serverless v2 with connection pooling. For Redis 8.10 caching, place ElastiCache in the same VPC and attach Lambda to private subnets.

Is Laravel Vapor worth the cost in 2026?

Laravel Vapor is the managed layer on top of Bref and AWS. It handles deployments, environment management, databases, queues, and scheduling for Laravel 12 and 13 applications. If your stack is already Laravel, Vapor removes most serverless wiring.

Vapor pricing has two parts: the Vapor subscription (roughly USD 39–399/month depending on team size) plus AWS usage. A low-traffic API might cost USD 5–20/month in AWS fees. A busy app with RDS, SQS, and CloudFront can exceed USD 200/month quickly. Budget Rs 15,000–30,000/month (~USD 110–220) as a starting envelope for a production Laravel API in Nepal-region AWS.

Vapor deployment workflow

  1. Install laravel/vapor-cli and laravel/vapor-core via Composer 2.10.
  2. Run vapor login and vapor init in your Laravel project root.
  3. Configure vapor.yml with memory, timeout, database, and queue settings.
  4. Deploy with vapor deploy production—assets upload to S3, functions update atomically.
  5. Point your domain via Vapor's DNS or CloudFront distribution.
# vapor.yml (excerpt)
id: 12345
name: booking-api
environments:
  production:
    memory: 1024
    cli-memory: 512
    runtime: php-8.3
    build:
      - 'composer install --no-dev'
      - 'php artisan event:cache'
    deploy:
      - 'php artisan migrate --force'

Vapor shines for teams that want Laravel conventions without managing Lambda config files. I've seen it work well for webhook-heavy integrations similar to an eSewa payment integration where the main site stays on VPS but payment callbacks run serverless.

It is a poor fit when you need WebSockets, long-running CLI scripts, or heavy session-based admin panels. Vapor pushes you toward S3 storage, database sessions, and queue-driven architecture. That matches modern Laravel patterns, but migrating a legacy monolith hurts.

How does Google Cloud Run compare for PHP containers?

Cloud Run runs Docker containers that scale to zero and bill per request plus vCPU-seconds. You build a standard PHP-FPM + Nginx image—or use Laravel Octane with RoadRunner or Swoole for faster boot. This path feels closest to traditional hosting while keeping automatic scaling.

See the RoadRunner gRPC guide for how Octane-style runtimes reduce per-request bootstrap cost. On Cloud Run, a slim Octane container often beats Lambda cold starts for Symfony 8.1 or Laravel 13 APIs.

Sample Cloud Run Dockerfile

FROM php:8.4-cli
RUN apt-get update && apt-get install -y libzip-dev \
    && docker-php-ext-install pdo_mysql zip opcache
COPY --from=composer:2.10 /usr/bin/composer /usr/bin/composer
WORKDIR /app
COPY . .
RUN composer install --no-dev --optimize-autoloader
CMD ["php", "artisan", "octane:start", "--server=roadrunner", "--host=0.0.0.0", "--port=8080"]

Deploy with gcloud run deploy. Set min instances to 1 if cold starts matter for user-facing APIs. Cloud Run allows up to 60-minute request timeouts on configured services—far beyond Lambda's API Gateway limit.

Cloud Run PHP Request FlowClientCloud RunPHP OctaneCloud SQLMySQL 8.4MemorystoreRedis cacheContainer scales 0 to N; min-instances avoids cold boot
Google Cloud Run runs PHP in containers with optional Cloud SQL and Redis—closer to VPS architecture than Lambda.

Cloud Run fits Symfony 8.1 apps that need PHP 8.4.1 minimum and long request windows. Multi-tenant SaaS with per-tenant scaling also maps well. Review Laravel multi-tenancy approaches before splitting tenants across Cloud Run services.

What about Azure and hybrid serverless patterns?

Azure Functions does not offer maintained PHP runtimes in 2026. Azure Container Apps is the practical choice: deploy the same Docker image you would use on Cloud Run, connect to Azure Database for MySQL or PostgreSQL 18, and scale with KEDA triggers including HTTP, queues, and cron.

Hybrid patterns often win on real client projects. Keep the main Laravel app on a VPS managed through Linux system administration. Offload image processing, PDF generation, or webhook ingestion to Lambda or Cloud Run. This mirrors how legal-tech portals handle document uploads on the primary server but process conversions asynchronously.

For CI/CD, serverless does not remove the pipeline. You still lint, test, and deploy artifacts. The DevOps roadmap for 2026 applies—only the target changes from SSH plus Deployer 7 to vapor deploy or gcloud run deploy.

Which serverless PHP platform should you pick?

Use a decision matrix grounded in traffic shape, framework, and ops capacity. No single platform wins every workload.

CriteriaAWS Lambda + BrefLaravel VaporGoogle Cloud RunAzure Container AppsVPS + PHP-FPM
Best forWebhooks, cron, queue workersLaravel-only teamsContainerised APIs, SymfonyAzure ecosystem shopsSteady traffic, admin UIs, WordPress
Cold start200 ms–2 s typicalSame (uses Lambda)500 ms–3 s (mitigate with min instances)Similar to Cloud RunNone (always warm)
Max HTTP timeout29 s (API Gateway)29 s defaultUp to 60 minConfigurable, long requests OKUnlimited (set in Nginx)
PHP versions8.2–8.4 via layers8.2–8.3 managedAny (your Dockerfile)Any (your Dockerfile)8.3/8.4/8.5 side-by-side
Database fitNeeds RDS Proxy / AuroraManaged RDS via VaporCloud SQL, connection poolingAzure DB flexible serverDirect MySQL 9.7 / MariaDB 12.3
Ops burdenHigh (YAML, IAM, VPC)Low for LaravelMedium (Docker + GCP)Medium (Docker + Azure)High but familiar
Cost at low trafficVery low (free tier)Sub + AWS feesLow with scale-to-zeroLow with scale-to-zeroFixed Rs 1,500–5,000/mo (~USD 11–37)
Laravel 13 fitGood with tuningExcellentExcellent with OctaneGoodExcellent (default)

WordPress 7.1 and WooCommerce 11.1 remain poor serverless candidates. Persistent filesystem expectations, plugin compatibility, and page-cache plugins assume a local disk or shared storage. Keep WordPress on VPS or managed WordPress hosting via WordPress development services.

Serverless PHP Decision TreeNew PHP workload?Steady trafficAdmin + sessionsBursty APIWebhooks, cronLong jobs60 min exportsVPS + PHP-FPMLambda / VaporCloud Run
Choose VPS for steady session-heavy apps; Lambda or Vapor for event-driven Laravel; Cloud Run for long-running containerised PHP.

Cost reality check

Serverless is not automatically cheaper. A Rs 3,000/month (~USD 22) VPS comfortably runs a Laravel 12 app with MySQL, Redis, and cron. The same app on Vapor plus RDS can cost 3–5× more at moderate traffic. Serverless wins when traffic is sparse or spiky—internal admin tools used twice a day, or payment webhooks that fire unpredictably.

Use the JSON formatter to inspect Lambda CloudWatch log payloads during debugging. Structured logging matters more when you cannot SSH into a box.

How do you migrate PHP to serverless without breaking production?

Incremental migration beats a big-bang rewrite. A pattern I've used on production Laravel applications:

  1. Audit state — list filesystem writes, session driver, cache driver, and cron entries.
  2. Externalise storage — move storage/ and uploads to S3-compatible object storage.
  3. Switch sessions and cache — database or Redis sessions; never file-based sessions on Lambda.
  4. Extract one route — deploy a single webhook endpoint serverless while the main app stays on VPS.
  5. Move queues — replace database queue driver with SQS or Redis-backed workers.
  6. Cut over DNS — point API subdomain to API Gateway or Cloud Run after load testing.

Watch for packages that assume long-lived processes. PHP Fibers help concurrent I/O inside a single invocation, but they do not replace a persistent worker for heavy background jobs. For API design during split deployments, follow consistent API versioning strategies.

Hybrid PHP ArchitectureVPS MonolithLaravel 13 + MySQL 9.7Admin, Blade, queuesDeployer 7 releasesServerless EdgeLambda webhooksPDF / image jobsScheduled sync tasksShared RDS / SQS / S3Both tiers connect via VPC or public API
Hybrid serverless PHP: keep the main app on VPS, offload event-driven endpoints to Lambda or Cloud Run.

Database choice still matters. MariaDB vs MySQL comparisons apply whether the database sits on VPS or Aurora. Serverless functions benefit from managed databases with autoscaling storage.

For new Laravel projects, read why developers should learn Laravel in 2026 before committing to Vapor. Framework fluency reduces migration risk either way.

Key Takeaways

  • Serverless PHP in 2026 means Lambda + Bref, Laravel Vapor, or container platforms— not native PHP on every cloud function service.
  • Pick Lambda or Vapor for Laravel webhooks, queues, and cron; pick Cloud Run when requests exceed 29 seconds or need custom PHP 8.5 images.
  • Keep WordPress, WooCommerce, and session-heavy admin panels on VPS—the hosting model still fits better.
  • Plan for cold starts, RDS Proxy, and S3 storage before migrating; file-based sessions and local disks break on Lambda.
  • Hybrid architectures often deliver the best ROI: VPS monolith plus serverless workers for spikes and integrations.
  • Compare total cost—including RDS, SQS, and Vapor subscription—not just per-invocation Lambda pricing.

People Also Ask

Can PHP run on AWS Lambda in 2026?

Yes. Bref provides maintained PHP runtimes for AWS Lambda, supporting PHP 8.2 through 8.4 via layers. You package your application with Composer, deploy through Serverless Framework or Laravel Vapor, and connect to RDS through RDS Proxy for connection pooling.

Is Laravel Vapor the only way to run Laravel serverless?

No. You can deploy Laravel on Cloud Run or Azure Container Apps using Docker and Octane. Vapor is the lowest-friction path for AWS Lambda specifically. It manages infrastructure, SSL, and queue workers through Laravel-native commands.

Why is serverless PHP slower on cold starts?

Each Lambda invocation may boot a fresh PHP process, load Composer autoloaders, and initialise Laravel service providers. Container platforms face similar boot costs unless min instances stay warm. OPcache and slim service providers reduce the penalty.

When should you avoid serverless for PHP entirely?

Avoid serverless when your app needs local filesystem writes, long-lived WebSockets, heavy admin sessions, or predictable 24/7 traffic on a budget. A Rs 3,000/month VPS with PHP-FPM 8.4 often outperforms and undercuts a fully managed serverless stack.

Pick the right PHP hosting model for your traffic

Serverless PHP options in 2026 compared boil down to traffic shape and framework—not hype. Lambda and Vapor excel at event-driven Laravel workloads. Cloud Run suits containerised APIs with longer timeouts. Most business-critical sites I maintain still run on VPS with Deployer 7, and that remains the sane default for 2026.

Before you re-architect, profile your traffic and list filesystem dependencies. If you want help choosing between serverless and traditional hosting for a Laravel or API project, API development and web development services cover architecture through deployment. You can also review shipped work on the portfolio or contact us to discuss your stack.

Frequently Asked Questions

Code on a platform that scales to zero and bills per request or CPU-second, with no OS patching or PHP-FPM reloads by you. PHP always ships as custom runtimes or containers—not native FaaS like Node.js.

Yes. Bref provides maintained PHP runtimes for Lambda, supporting PHP 8.2 through 8.4 via layers. Package with Composer, deploy via Serverless Framework or Laravel Vapor, and use RDS Proxy for database connection pooling.

Bref packages PHP using custom runtimes and layers. You deploy a serverless.yml file through the Serverless Framework or SAM, bundling Composer dependencies into the artifact. The handler bootstraps your front controller—public/index.php for Laravel or Symfony. Configure Bref layers for PHP 8.3 or 8.4, HTTP API events, and region such as ap-south-1. Laravel and Symfony both work, but boot time directly affects cold-start latency, so keep service providers lean.

Vapor subscription runs roughly USD 39–399/month plus AWS usage. Low-traffic APIs may add USD 5–20 in AWS fees; busy stacks with RDS, SQS, and CloudFront can exceed USD 200/month.

Vapor is the managed layer on Bref and AWS for Laravel 12 and 13. It handles deployments, environments, databases, queues, and scheduling through vapor deploy and vapor.yml—removing most Lambda wiring for Laravel-only teams. It works well for webhook-heavy integrations where the main site stays on VPS. It is a poor fit for WebSockets, long CLI scripts, or heavy session-based admin panels. Budget Rs 15,000–30,000/month (~USD 110–220) as a starting envelope for a production Laravel API in Nepal-region AWS, including subscription and usage.

Each Lambda invocation may boot a fresh PHP process, load Composer autoloaders, and initialise Laravel service providers. A heavy Laravel 13 app with dozens of service providers pays a real penalty—typically 200 ms to 2 s on Lambda depending on memory and package size. Container platforms on Google Cloud Run face similar costs of 500 ms to 3 s unless you set min instances to 1. Slim service providers and OPcache tuning reduce the penalty but never eliminate it entirely.

MySQL on RDS does not handle hundreds of short-lived Lambda invocations opening fresh connections well. Use RDS Proxy or Aurora Serverless v2 with connection pooling. For Redis 8.10 caching, place ElastiCache in the same VPC and attach Lambda to private subnets. On VPS you connect directly to MySQL 9.7 or MariaDB 12.3, but serverless functions need managed databases with pooling because each invocation is short-lived and connection churn adds latency and can exhaust database limits.

Cloud Run runs Docker containers that scale to zero and bill per vCPU-second. You build a standard PHP-FPM plus Nginx image or use Laravel Octane with RoadRunner for faster boot. It allows up to 60-minute request timeouts—far beyond Lambda's 29-second API Gateway limit. Cold starts run 500 ms to 3 s but min instances mitigate that. Symfony 8.1 apps needing PHP 8.4.1 minimum and long request windows fit Cloud Run better than Lambda. Lambda plus Bref wins for webhooks, cron, and queue workers at very low traffic.

Azure Functions does not offer maintained PHP runtimes in 2026. Azure Container Apps is the practical Azure choice: deploy the same Docker image you would use on Cloud Run, connect to Azure Database for MySQL or PostgreSQL 18, and scale with KEDA triggers for HTTP, queues, and cron. This mirrors the container model rather than function-as-a-service. Teams already invested in the Azure ecosystem get a viable path, but there is no first-class PHP FaaS runtime comparable to Bref on Lambda.

Match platform to traffic shape and framework. Use AWS Lambda plus Bref or Laravel Vapor for webhooks, cron, and queue workers on Laravel. Pick Google Cloud Run or Azure Container Apps for containerised APIs, Symfony 8.1, or requests exceeding 29 seconds. Keep steady traffic, admin UIs, WordPress 7.1, and WooCommerce 11.1 on VPS with PHP-FPM—none of the serverless options fit session-heavy or filesystem-dependent workloads well. Hybrid patterns often win: VPS monolith plus serverless workers for spikes and integrations.

Skip serverless when your app needs local filesystem writes, long-lived WebSockets, heavy admin sessions, or predictable 24/7 traffic on a budget. A Rs 3,000/month (~USD 22) VPS with PHP-FPM 8.4 often outperforms and undercuts a fully managed serverless stack.

No. You can deploy Laravel on Google Cloud Run or Azure Container Apps using Docker and Laravel Octane with RoadRunner or Swoole. Vapor is the lowest-friction path for AWS Lambda specifically—it manages infrastructure, SSL, and queue workers through Laravel-native vapor deploy commands. For teams not committed to AWS, Cloud Run with a standard Dockerfile and gcloud run deploy offers excellent Laravel 13 fit with Octane, especially when requests exceed Lambda's HTTP timeout limits.

WordPress 7.1 and WooCommerce 11.1 remain poor serverless candidates. Persistent filesystem expectations, plugin compatibility, and page-cache plugins assume a local disk or shared storage. Serverless platforms like Lambda have no persistent local filesystem, and plugin behaviour breaks unpredictably. Keep WordPress on VPS or managed WordPress hosting. The same applies to session-heavy admin panels on Laravel monoliths—Vapor pushes you toward S3 storage, database sessions, and queue-driven architecture, which legacy WordPress stacks cannot adopt without a full rewrite.

Not automatically. A Rs 3,000/month (~USD 22) VPS comfortably runs a Laravel 12 app with MySQL, Redis, and cron. The same app on Vapor plus RDS can cost three to five times more at moderate traffic. Serverless wins when traffic is sparse or spiky—internal admin tools used twice a day, or payment webhooks that fire unpredictably. Compare total cost including RDS, SQS, CloudFront, and the Vapor subscription, not just per-invocation Lambda pricing. Fixed VPS at Rs 1,500–5,000/month (~USD 11–37) stays the sane default for steady production traffic.

Incremental migration beats a big-bang rewrite. Audit filesystem writes, session driver, cache driver, and cron entries first. Move storage and uploads to S3-compatible object storage. Switch sessions and cache to database or Redis—never file-based sessions on Lambda. Deploy a single webhook endpoint serverless while the main app stays on VPS. Replace the database queue driver with SQS or Redis-backed workers. Point an API subdomain to API Gateway or Cloud Run after load testing. Watch for packages that assume long-lived processes; PHP Fibers help concurrent I/O inside one invocation but do not replace persistent workers for heavy background jobs.

Share this article

0 Comments

Leave a comment

Your email is not published. Comments appear once they have been read. Sign in to have your details filled in.

Quick Contact Options
Choose how you want to connect me: