Skip to content

FilesystemArtifactWriter

Writes an EmittedArtifact to a real file, via a write-to-temp-then-rename so a concurrent request (or an opcache-warmed worker) never observes a partially written compiled validator file — rename() is atomic on the same filesystem, unlike a direct file_put_contents() to the final path.

final class FilesystemArtifactWriter implements ArtifactWriter

ImplementsArtifactWriter
Since1.0.0
SourceSupport/Compiler/FilesystemArtifactWriter.php
MethodDescription
write(EmittedArtifact $artifact, string $target): voidCreates the target directory when missing, writes the source to a process-unique temporary file beside it and renames that into place.

public function write(EmittedArtifact $artifact, string $target): void

Creates the target directory when missing, writes the source to a process-unique temporary file beside it and renames that into place.

A failed rename removes the temporary file before throwing.

ParameterTypeDescription
$artifactEmittedArtifact
$targetstring
ThrowsWhen
RuntimeExceptionIf the directory cannot be created, the temporary file cannot be written, or the rename fails.