system • Started as a standalone version • Later I added a cloud hosted version • The aim to have both use the same basic code base with cloud being modified for multi-tenant • Have the ability to test without having to worry about the multi-tenantancy part
switchBySubdomain(string $subdomain): void; public function switchById(string $id): void; } interface TenantProvider { public function getTenant(): Tenant; }
a Scheduler message 2. Create a messenger stamp to show it’s been created for a tenant 3. Create a messenger middleware to create a message for each tenant 4. Create a messenger middleware to switch to the correct tenant
{ return $stack->next()->handle($envelope, $stack); } // Check if the message has already been duplicated if (null !== $envelope->last(SchedulerStamp::class)) { return $stack->next()->handle($envelope, $stack); } // ...
{ public function __construct( private TenantSwitcher $tenantSwitcher, ) { } public function handle(Envelope $envelope, StackInterface $stack): Envelope { // ...