- What Laravel versions does `laravel/vapor-core` support, and how do I check compatibility?
- `laravel/vapor-core` is officially tested with Laravel 10–13. Verify compatibility by checking the [Vapor documentation](https://docs.vapor.build) or the package’s [changelog](https://github.com/laravel/vapor-core/releases). If using an older version, upgrade Laravel first or check for community patches, as serverless optimizations may not apply.
- How do I install `laravel/vapor-core` in an existing Laravel project?
- Run `composer require laravel/vapor-core` in your project directory. The package auto-registers service providers when detected in a Vapor environment (via `VAPOR_ENV`). Ensure your `bootstrap/app.php` includes `VaporServiceProvider` if manually bootstrapping. No additional configuration is needed for basic AWS Lambda integration.
- Does `laravel/vapor-core` work with Laravel Octane or traditional PHP-FPM?
- Yes, it supports both. Octane (for real-time features) and PHP-FPM (for non-serverless setups) are compatible, but the package skips registration on non-Vapor platforms. For Octane, ensure your `vapor.yml` config aligns with Lambda’s execution model. FPM edge cases (e.g., GET request bodies) are explicitly addressed in the core.
- Can I use `laravel/vapor-core` with non-AWS serverless providers like Google Cloud Functions?
- No, this package is tightly coupled with AWS Lambda, SQS, and RDS. Porting to other providers would require rewriting AWS-specific integrations (e.g., Lambda context handling, SQS queues). For multi-cloud flexibility, consider abstracting AWS dependencies or using a wrapper like `aws/aws-sdk-php` with custom logic.
- How does `laravel/vapor-core` handle cold starts in AWS Lambda?
- Cold starts are mitigated via Laravel’s optimized bootstrapping and Vapor’s provisioned concurrency. The package reduces initialization overhead by lazy-loading services and skipping non-essential providers. For critical low-latency apps, enable provisioned concurrency in AWS Lambda or use warm-up strategies (e.g., scheduled CloudWatch events).
- Are there testing challenges with `laravel/vapor-core`, and how can I mock AWS services?
- Testing is non-deterministic due to AWS service throttling and cold starts. Use Laravel’s `Mockery` or `AWS SDK for PHP` mocks to simulate Lambda/SQS interactions. The package includes PHPUnit 10–12 compatibility fixes, but custom test setups may be needed for stateful operations. Avoid testing cold starts in CI; use warm pools or localstack for local AWS emulation.
- Can I deploy a hybrid app (Vapor + traditional servers like EC2) with this package?
- Yes, but with caveats. The package auto-detects `VAPOR_ENV` and skips registration on non-Vapor platforms. For hybrid setups, manually conditionally load `VaporServiceProvider` in `bootstrap/app.php` (e.g., `if (app()->environment('vapor'))`). Shared state (e.g., sessions, caches) must use external stores like Redis or DynamoDB, as Lambda is stateless.
- What AWS services are required, and how do I configure IAM permissions?
- Core dependencies include Lambda, SQS (queues), RDS/ElastiCache (databases), and S3 (storage). IAM roles must grant execute permissions for Lambda functions and access to SQS/RDS. Use AWS SAM or Vapor CLI to deploy with pre-configured IAM policies. For VPC-bound Lambdas, ensure your security groups allow outbound traffic to AWS services.
- How do I handle large Laravel apps that exceed AWS Lambda’s 50MB unzipped limit?
- Optimize your deployment by externalizing assets (e.g., uploads to S3), lazy-loading non-critical services, and using Lambda layers for shared dependencies. The package supports S3-compatible storage (e.g., MinIO), but large vendor directories may still require splitting into multiple functions. Profile your deployment with `vapor deploy --profile` to identify bottlenecks.
- Are there alternatives to `laravel/vapor-core` for serverless Laravel deployments?
- For AWS Lambda, alternatives include `spatie/laravel-serverless` (more flexible but less Laravel-centric) or building custom Bref/Serverless Framework integrations. For multi-cloud, consider `google/cloud-functions` or Azure Functions SDKs, but these lack Laravel’s deep integration. Vapor Core is the most mature option for AWS-specific Laravel serverless workflows.