pccomponentes / topic-generator
Topic Generator
Installs: 57 195
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 6
Forks: 2
Open Issues: 0
Requires
- php: ^7.4 | ^8.0
Requires (Dev)
This package is auto-updated.
Last update: 2024-11-18 17:12:27 UTC
README
This is a helper that standardizes topic generation in messages (commands and events).
Installation
-
Install via composer
composer require pccomponentes/topic-generator
Usage
At least two classes are required: Company
and Service
.
-
Company
<?php declare(strict_types=1); class PcComponentes extends \PcComponentes\TopicGenerator\Company { private const COMPANY_NAME = 'pccomponentes'; public function name(): string { return self::COMPANY_NAME; } }
-
Service
<?php declare(strict_types=1); class Picking extends \PcComponentes\TopicGenerator\Service { private const SERVICE_NAME = 'picking'; public function name(): string { return self::SERVICE_NAME; } }
Then the messages would be generated in this way:
<?php declare(strict_types=1); $version = '1'; $type = 'command'; $resource = 'parcel'; $name = 'register'; $topic = \PcComponentes\TopicGenerator\Topic::generate( PcComponentes::instance(), Picking::instance(), $version, $type, $resource, $name ); echo $topic;
The result would be this:
pccomponentes.picking.1.command.parcel.register