Skip to content

🥕 🍰 キャロットケーキ A CakePHP plugin for pub/sub of rabbitMQ exchanges & queues

License

Notifications You must be signed in to change notification settings

alvarium/carrot-cake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kyarottokēki plugin for CakePHP

pipeline status coverage status

Carrot Cake is a CakePHP plugin for publishing and subscribing to RabbitMQ queues/exchanges.

BTW we like to pronounce it like in japanese: Kyarottokēki (キャロットケーキ), that's why we wrote it that way in the title 😄.

Installation

You can install this plugin into your CakePHP application using composer.

The recommended way to install composer packages is:

composer require alvarium/carrot-cake

Usage

Configuring

You can create a defaults settings file by adding a rabbit.php file under your config file. The plugin will take that settings as defaults but you'll be able to overwrite them later on each loaded component.

The contents of such file can be with any of the following settings:

<?php

return [
  'rabbit' => [
    'server' => [
      'host' => 'rabbit',
      'port' => 5672,
      'user' => 'guest',
      'password' => 'guest',
      'vhost' => '/',
      'type' => 'direct',
    ],
    'behavior' => [
      // Check out the behavior section for details about its settings
    ],
    'component' => [
      // Check out the component section for details about its settings
    ],
  ],
];

Publisher Behavior

First you'll need to load the behavior in the desired table, when doing so you can override any of the previously defined settings + some specific settings for the behavior, like the used exchange (by default is tablename):

<?php
namespace App\Model\Table;

use Cake\ORM\Table;
class ArticlesTable extends Table
{
  public function initialize(array $config)
  {
    parent::initialize($config);

    $this->addBehaviors([
      'Alvarium/CarrotCake.Publisher' => [
        'vhost' => '/custom-vhost',
        'exchange' => 'custom_exchange_name',
      ],
    ])
  }
}

By default the behavior will send payloads to exchange.route, where route can be any of:

  • created
  • updated
  • deleted

Of course you can change these too by setting a routes key and set your desired names for each route:

$this->addBehaviors([
  'Alvarium/CarrotCake.Publisher' => [
    'routes' => [
      'create' => 'published',
      'update' => 'changed',
      'delete' => 'unpublished',
    ],
  ],
])

Checklist

  • Publisher
    • Behavior
    • Component
  • Consumer
    • Component

License

MIT License

Copyright Alvarium.io (c) 2019

About

🥕 🍰 キャロットケーキ A CakePHP plugin for pub/sub of rabbitMQ exchanges & queues

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages