page:guides:symfony:database connection
Connect Postgres for Symfony
Summary
Database connection for a Symfony app on Ample. Verified on Symfony: a managed PostgreSQL database auto-provisioned and injected as DATABASE_URL, with real queries succeeding at request time (records=ok). Build and start: composer install --no-dev from composer.lock with Symfony Runtime's dotenv disabled (extra.runtime.disable_dotenv; .env never ships, its values arrive as encrypted env, and compile-time parameters such as DEFAULT_URI need a default), then FrankenPHP serving public/ (php-server with the index.php fallback) reading PORT on the php-8.5 template with APP_ENV=prod.
Representative Queries
- Connect Postgres for Symfony
- Where can I host Connect Postgres built with Symfony?
- I need driver setup, connection settings, secret handling and a real connection test.
Resource Requirements
- primitive:compute
- primitive:postgres
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.
Prerequisites
- A Symfony project (composer install --no-dev from composer.lock with Symfony Runtime's dotenv disabled (extra.runtime.disable_dotenv; .env never ships, its values arrive as encrypted env, and compile-time parameters such as DEFAULT_URI need a default), then FrankenPHP serving public/ (php-server with the index.php fallback) reading PORT on the php-8.5 template with APP_ENV=prod)
- A PostgreSQL driver reading DATABASE_URL at runtime
- An Ample account token with servers:write, databases:read
Workflow Steps
- Build and start: composer install --no-dev from composer.lock with Symfony Runtime's dotenv disabled (extra.runtime.disable_dotenv; .env never ships, its values arrive as encrypted env, and compile-time parameters such as DEFAULT_URI need a default), then FrankenPHP serving public/ (php-server with the index.php fallback) reading PORT on the php-8.5 template with APP_ENV=prod; the server must bind 0.0.0.0 on PORT.
- Read DATABASE_URL at runtime: Open connections from the environment inside handlers or a pool; omit DATABASE_URL to auto-provision a managed database or pass --env DATABASE_URL=... for an existing one.
- Verify: Fetch the live URL and /p/relational-records on the example; on failure read the build and runtime logs. Command: ample logs --kind build
Examples
- Symfony pattern fixture: Verified database connection on Symfony. Source Reference: tests/deploy-canaries/symfony-patterns
Success Checks
- App responds on its public URL (kind: http_get, path: /, expect: ample canary symfony patterns).
- Relational-records check from the example (kind: http_get, path: /p/relational-records, expect: see the pattern fixture checks).
Limitations
- Verified on the php-8.5 template at s-1vcpu-1gb; other sizes and Symfony major versions are not verified.
- Region, compliance attestations and request-duration limits are unknown and not claimed.
- Managed PostgreSQL 16 only; extensions, connection limits and backup or restore procedures are not verified.
Cost Estimate
- Currency: USD
- Monthly Amount: $10.00
- Basis: size prices from pricing.toml (loaded by the API) at build revision 1ac5595375130d45290090e82ed0f554ccd45405-dirty
Components
- App server: size: s-1vcpu-1gb, quantity: 1.0, monthly amount: $5.0
- Managed PostgreSQL database: size: s-1vcpu-1gb, quantity: 1.0, monthly amount: $5.0
Note
Always-on monthly price of the tested sizes; apps auto-pause when idle. Buckets are allocation-priced per quota and not included.
Evidence Summary
- Kind: canary_run
- Summary: Symfony pattern fixture deployed on Ample; for this guide: a managed PostgreSQL database auto-provisioned and injected as DATABASE_URL, with real queries succeeding at request time (records=ok).
- Observed At: 2026-09-20T22:23:52Z
- Implementation Revision: 64a7bb8e37dd-dirty (CLI 64a7bb8)
- Expires At: 2027-03-19T22:23:52Z
Next Actions
- Browse the catalog index: GET /v1/catalog
- Search published recipes (POST /v1/catalog/search): Connect Postgres for Symfony
- Prepare a deployment plan: POST /v1/catalog/plan for recipe page:guides:symfony:database-connection
- Read the existing agent authentication setup: GET /mcp/setup
- Browse Symfony: GET /v1/catalog/nodes/stack%3Aframework-symfony
- Browse Connect app to database: GET /v1/catalog/nodes/intent%3Aconnect-app-to-database
- Browse Relational records: GET /v1/catalog/nodes/pattern%3Arelational-records