Repository navigation
Internals Response Senders ImageSender
Framework Internals · Subsystem overview · Developer guide
Source: awt_src/classes/response/senders/ImageSender.php · Snapshot 8411f4287706.
Response builds status, headers and data/file payloads, chooses a MIME sender, and emits HTTP output. JSON arrays are wrapped in a status/message/data envelope.
class ImageSender extends AbstractSenderDeclarations below preserve visibility, type, default and modifiers exactly. A typed property without an initializer remains uninitialized until its constructor or another method assigns it. Mutable fields belong to this instance unless marked static; readonly fields can be initialized once. Constructor-promoted properties are also listed below.
| Member | Declaration | Purpose or source contract |
|---|---|---|
| const MIMES | private const MIMES = [ 'image/jpeg', 'image/png', 'image/gif', 'image/webp', 'image/svg+xml', 'image/x-icon', 'image/bmp', 'image/tiff', 'image/avif', ]; |
State or definition consumed by the methods below; reads and writes are preserved in their implementation traces. |
| Method | Signature |
|---|---|
| supportedMimes | public function supportedMimes(): array |
| send | public function send(mixed $payload, int $status, array $headers): void |
| mimeFromPath | private function mimeFromPath(string $path): string |
public function supportedMimes(): arrayReturn expressions (including local callbacks): self::MIMES.
Implementation, validation guards and interaction order
public function supportedMimes(): array
{
return self::MIMES;
}public function send(mixed $payload, int $status, array $headers): void| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$payload |
mixed $payload |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
$status |
int $status |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
$headers |
array $headers |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
$payload must be a file path. MIME is resolved from the file's extension.
External effects include header.
Implementation, validation guards and interaction order
/**
* $payload must be a file path.
* MIME is resolved from the file's extension.
*/
public function send(mixed $payload, int $status, array $headers): void
{
$path = (string) $payload;
$this->requireReadable($path);
$mime = $this->mimeFromPath($path);
$size = $this->fileSize($path);
$this->emitStatus($status);
$this->emitContentType($mime);
header("Content-Length: $size");
$this->emitHeaders($headers);
$this->streamFile($path);
}private function mimeFromPath(string $path): string| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$path |
string $path |
Filesystem or route path as defined by the owning component; no universal path normalization is implied. |
Return expressions (including local callbacks): match ($ext) { 'jpg', 'jpeg' => 'image/jpeg', 'png' => 'image/png', 'gif' => 'image/gif', 'webp' => 'image/webp', 'svg' => 'image/svg+xml', 'ico' => 'image/x-icon', 'bmp' => 'image/bmp', 'tiff', 'tif' => 'image/tiff', 'avif' => 'image/avif', default => throw new \RuntimeException("Unsupported image extension: '.$ext'."), }.
Explicit exceptions: \RuntimeException. The guards in the implementation below show when each is raised; exceptions from collaborators also propagate unless caught.
Implementation, validation guards and interaction order
private function mimeFromPath(string $path): string
{
$ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
return match ($ext) {
'jpg', 'jpeg' => 'image/jpeg',
'png' => 'image/png',
'gif' => 'image/gif',
'webp' => 'image/webp',
'svg' => 'image/svg+xml',
'ico' => 'image/x-icon',
'bmp' => 'image/bmp',
'tiff', 'tif' => 'image/tiff',
'avif' => 'image/avif',
default => throw new \RuntimeException("Unsupported image extension: '.$ext'."),
};
}AWT Framework Wiki · Home · Installation Guide · Developer Guide · Framework Internals
Philosophy · Architecture · Known discrepancies · Verification
Installation Guide
Developer Guide
- Learning sequence
- First package
- Package structure
- Lifecycle
- Runtimes
- Events and objects
- Routing and controllers
- Views and resources
- Database and models
- Storage and caching
- Configuration and CLI
- Responses and errors
- Extension points
Framework Internals
- Architecture
- Bootstrap
- Packages
- Runtime
- Events and context
- Objects
- HTTP routing and controllers
- Rendering
- Blade integration
- Database
- Models
- Storage and caching
- Settings
- CLI
- Identity and sessions
- Responses
- Errors
- Complete source inventory
Documentation notes