A shorter way to define a message
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 35/100
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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?
- Linguagem predominante
- PHP
- Estrelas
- 60
- Forks
- 32
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de yiisoft/queue
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
-
Dificuldade 4/5 1-2 dias Facilidade para iniciantes 47/100
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 54/100
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 45/100
Todas as issues de yiisoft/queue
Issues semelhantes
-
PHP workflow streaming requests buffer the full SSE responseTalvez já em andamento @Winoren assumiu hoje. Abertareview: medium
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
langgenius/dify#44270 · 1 comentário · 1 reação ·
Mantenedores costumam responder em até 1 dia
-
bug customer-reported
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 90/100
MagnaCapax/PMSS#1085 ·
Mantenedores costumam responder em até 5 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 83/100
nunomaduro/collision#375 ·
-
enhancement good first issue hacktoberfest help wanted
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
thetheago/laravel-seeder-versioning#19 ·
Mantenedores costumam responder em até 1 dia