# Host form collection with Laravel: file attachments

Deploy a form collection built with Laravel on Ample using the browser file uploads pattern. Compute runs the app in an isolated microVM behind a public HTTPS URL, a managed PostgreSQL 16 database is auto-provisioned and injected as DATABASE_URL, a private S3-compatible bucket holds objects with credentials delivered as encrypted environment variables. Verified on Laravel: content-type and size validation that rejects disallowed files, an object written to a private bucket and a row linking the record to the object key (reject=ok upload=ok linked=ok). Not separately tested: your upload UI, allowed types, size limits and virus scanning; treat the form collection-specific behavior as your application code.

## Representative Queries
- Host form collection with Laravel: file attachments
- Where can I host Form collection built with Laravel?
- I need a restricted upload flow, file validation and record-to-object linkage.

## Resource Requirements
- primitive:compute
- primitive:postgres
- primitive:s3-compatible-object-storage

## Infrastructure Requirements
- **Compute**: Apps run in isolated x86_64 Firecracker microVMs that auto-pause when idle and wake on request; sizes are the priced VM sizes.
- **Postgres**: Managed PostgreSQL 16 runs in its own microVM and is auto-provisioned when an app needs a database and no DATABASE_URL is supplied.
- **S3-compatible object storage**: Buckets are S3-compatible with issued credentials; PutObject and GetObject are verified by canary. Other S3 operations are not verified.

## Prerequisites
- A Laravel project that builds and starts with the documented commands (composer install --no-dev from composer.lock, then FrankenPHP serving public/ (php-server with the index.php fallback) reading PORT on the php-8.5 template).
- A PostgreSQL driver reading DATABASE_URL at runtime (auto-provisioned when omitted, or supplied with --env).
- A bucket from `ample bucket create` with its credentials passed as encrypted S3_* environment variables.
- An Ample account token with servers:write, databases:read, buckets:read.

## Tested Configuration
- **Template**: php-8.5
- **Runtime**: php
- **Size**: s-1vcpu-1gb
- **Install**: composer install --no-dev --prefer-dist --no-interaction --no-progress --optimize-autoloader
- **Start**: frankenphp php-server --listen :$PORT --root public

## Workflow Steps
1. **Build and start**: composer install --no-dev from composer.lock, then FrankenPHP serving public/ (php-server with the index.php fallback) reading PORT on the php-8.5 template. The server must bind 0.0.0.0 on PORT.
2. **Implement the pattern on PostgreSQL**: The fixture's module implements browser file uploads: content-type and size validation that rejects disallowed files.
3. **Wire object storage**: Create the bucket(s), then pass endpoint, region, bucket and keys as --env values.
4. **Deploy**: Run the synchronous deploy once and read the result.
5. **Verify**: Fetch the live URL and the pattern self-test route(s).

## Examples
- **Laravel pattern fixture**: Multi-pattern Laravel app whose browser file uploads module was checked live.

## Success Checks
- App responds on its public URL
- Browser-file-uploads self-test

## Limitations
- Verified on the php-8.5 template at s-1vcpu-1gb with the example fixture. Other sizes, templates and Laravel major versions are not verified.

## Cost Estimate
- **Currency**: USD
- **Monthly Amount**: 10.0
- **Components**: 
  - App server: s-1vcpu-1gb, Quantity: 1.0, Monthly Amount: 5.0
  - Managed PostgreSQL database: s-1vcpu-1gb, Quantity: 1.0, Monthly Amount: 5.0
- Note: Always-on monthly price; apps and databases auto-pause when idle.

## Evidence Summary
- **Summary**: Laravel pattern fixture deployed on Ample. Checks passed for browser-file-uploads and configuration-secrets.
- **ObservedAt**: 2026-09-20T20:36:21Z

## Formats
- [HTML](/content/recipes/form-collection/laravel/attachments/index.html)
- [Markdown](/content/recipes/form-collection/laravel/attachments.md)
- [JSON](https://api.ample.computer/v1/catalog/recipes/page%3Arecipes%3Aform-collection%3Alaravel%3Aattachments)
