What is an item writer?
The item writer is used by the item job to load every processed item.
It can be any class implementing ItemWriterInterface.
What types of item writers exists?
Built-in item writers:
JsonLinesWriter: write items as a json string each on a line of a file.
ChainWriter: write items on multiple item writers.
ConditionalWriter: will only write items that are matching your conditions.
DispatchEventsWriter: will dispatch events before and after writing.
LaunchJobForEachItemWriter: launch another job for each items.
LaunchJobForItemsBatchWriter: launch another job for each item batches.
NullWriter: do not write items.
RoutingWriter: route writing to different writer based on your logic.
SummaryWriter: write items to a job summary value.
TransformingWriter: perform items transformation before delegating to another writer.
CallbackWriter: delegate items write operations to a closure passed at construction.
Item writers from bridges:
From
symfony/messengerbridge:DispatchEachItemAsMessageWriter: dispatch each item as a message in a bus.
From
doctrine/dbalbridge:DoctrineDBALInsertWriter: write items by inserting in a table via a Doctrine
Connection.DoctrineDBALUpsertWriter: write items by inserting/updating in a table via a Doctrine
Connection.
From
doctrine/persistencebridge:ObjectWriter: write items to any Doctrine
ObjectManager.
From
openspout/openspoutbridge:FlatFileWriter: write items to any CSV/ODS/XLSX file.
Item writers for testing purpose:
InMemoryWriter: write in a private var which can be accessed afterward in your tests.
TestDebugWriter: dummy item writer that you can use in your unit tests.
See also