Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

A shorter way to define a message

Offen
#344 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
35/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
php
Bereich
backend

Rechercherichtung

Start with the Quick Start message in README.md and messages-and-handlers.md to understand the existing manual message contract. The issue proposes an attribute or trait that derives message type and payload from public properties while keeping manual implementations available, but leaves the API and design open. Done means the package has a considered answer on whether to support this common case and, if pursued, a defined approach that preserves manual payload contracts.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Proposed new feature or change

The Quick Start message in README.md is 33 lines for two string properties. Message already covers getMeta()/withMeta(), so what is left per message class is getType(), getPayload() and a fromPayload() with hand-written validation:

public static function fromPayload(string $type, bool|int|float|string|array|null $payload): static
{
    if ($type !== self::TYPE) {
        throw new \InvalidArgumentException("Expected type \"" . self::TYPE . "\", got \"$type\".");
    }
    if (!is_array($payload)
        || !is_string($payload['url'] ?? null)
        || !is_string($payload['destinationPath'] ?? null)
    ) {
        throw new \InvalidArgumentException('Invalid data for ' . self::class . '.');
    }
    return new self($payload['url'], $payload['destinationPath']);
}

That is the same three checks in every message class in an application, and it is the first thing a newcomer meets in the README. Symfony Messenger and Laravel both take a plain object here.

The separation of payload from handler is well argued in messages-and-handlers.md and should stay — the request is for a short path for the common case, not a replacement. Something like an attribute or a trait that derives the type and the payload from the public properties:

#[AsMessage('download-file')]
final class DownloadFileMessage extends Message
{
    public function __construct(
        public readonly string $url,
        public readonly string $destinationPath,
    ) {}
}

with the manual implementation still available for messages that are a cross-application contract and need their payload shape pinned by hand.

Is this something you would consider in the package, or is it meant to stay application-side?

Vorherrschende Sprache
PHP
Sterne
60
Forks
32
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus yiisoft/queue

Alle Issues in yiisoft/queue

Ähnliche Issues

Weitere Issues zu PHP

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.