winter-doctrine package for the EntityManager and transaction manager. Writes run inside programmatic transactions via EmTransactionManager.
Prerequisites
You need PHP 8.5 or later with thepdo_pgsql extension. You also need a PostgreSQL server. The sample config points at localhost:5432, database appdb, user appuser — replace them with your own server.
Start PostgreSQL before you run the app:
Project structure
The sample uses this layout:Install dependencies
Require the framework and the Doctrine package:Source files
Switch between the source files. Each tab shows the exact file from the sample.- DoctrineSampleApplication.php
- model/User.php
- service/UserService.php
- controller/UserController.php
- bin/application.php
- composer.json
The single entry point.
#[EnableTransactionManagement] activates the transaction infrastructure used by the service.Configuration
Switch between the two config files.application.yml registers the module and the datasource, and create-table.sql creates the table.
- application.yml
- create-table.sql
The full sample file registers Replace the connection details with your own server, and
DoctrineModule, marks defaultdb as primary, and points the ORM at the model directory. It keeps only the server, app identity, module, and datasource keys:entityPaths with the absolute path of your src/model directory. See Configuration for every application.yml key.Run the app
Create the table, start the app, then create and read a user. 1. Create the table:Next steps
- Read the Doctrine module for DBAL access, multi-tenant datasources, and
#[Transactional]managers. - Browse all Libraries when you need Redis, Kafka, S3, or OpenSearch in the same app.