Product support

Visit this product's website for support.


  • Developer Tools
  • Utility

Apparatus is a library that consists of several modules, that may be useful when developing your plugins and themes.

Apparatus Messaging

  • Converts exceptions popups into noty notification.
  • Provides jQuery method to trigger notifications on requests success and anywhere in the code.
  • Allows setting up noty settings in Backend -> Settings
  • Binds to Flash::
  • Stylable with CSS

Routes Resolver

  • Easily find a route to component
  • Find pages that have components with specific properties.

Backend Injector

  • Provides methods to add css, js and ajax handlers into backend controllers

Dependency Injector

  • Easily inject dependencies into your components with typehints
  • Make your app faster and taking less resources

Scenario Factory

  • Event-based business logic scenario processor
  • For painless application behavior management & modification.
  • Alpha, [WiP]

Apparatus - Configuration and Usage

Apparatus Messaging

  • To enable messaging, drop apparatusFlashMessages into your layout, below jquery and framework.
  • To configure noty options, go to Backend -> Settings -> Apparatus: Messaging

This will allow you to select notification position and all other important noty settings.

Easiest way to style it with custom CSS, is to create a component overwrite

<!-- themes/mytheme/partials/apparatusFlashMessages -->

<div data-messaging-config
     data-msg-layout="{{ __SELF__.layout }}"
     data-msg-theme="{{ __SELF__.theme }}"
     data-msg-dismiss-queue="{{ __SELF__.dismissQueue }}"
     data-msg-template="{{ __SELF__.template }}"
     data-msg-animation-open="{{ __SELF__.openAnimation }}"
     data-msg-animation-close="{{ __SELF__.closeAnimation }}"
     data-msg-timeout="{{ __SELF__.timeout }}"
     data-msg-force="{{ __SELF__.force }}"
     data-msg-modal="{{ __SELF__.modal }}"
     data-msg-max-visible="{{ __SELF__.maxVisible }}"
{% flash %}
<script type="text/javascript" language="javascript">
    $(function () {
        $.apparatus.messaging.handleFlashMessage('{{ type }}', '{{ message }}');
{% endflash %}
    #noty_top_layout_container .list-group-item-danger {
        background-color: rgba(255, 44, 44, 0.7);
    #noty_top_layout_container .list-group-item-success {
        background-color: rgba(0, 128, 24, 0.7);
    #noty_top_layout_container .list-group-item-warning {
        background-color: rgba(240, 127, 22, 0.7);
  • Exceptions will be automatically shown as error notifications.
  • Manual triggering of notifications, eg in ajax requests or after redirects can be made with JS:
$.apparatus.messaging.handleFlashMessage('success', 'Some success message!');

or with Flash (will show up after site refresh, so join it with Redirect::to)

\Flash::success('Some success message!');
return \Redirect::to('/');

Routes Resolver

Routes resolver allows you to find a page with component (optionally with specific properties set) attached. You can find an exemplary class that looks for a route to component Account, considering :code page parameter.

Binding (in Plugin.php register() method or in your plugin Service Provider)

    function () {
        return new AccountComponentResolver($this->app->make('apparatus.route.resolver'), $this->app['config']);

Resolver class:

<?php namespace Keios\PaymentGateway\Core;

use Keios\Apparatus\Classes\RouteResolver;
use October\Rain\Config\Repository;

class AccountComponentResolver

    protected $config;

    protected $resolver;

    public function __construct(RouteResolver $resolver, Repository $config)
        $this->resolver = $resolver;
        $this->config = $config;

    public function resolveFor($code)
        $accountComponentName = $this->config->get('rainlab.user.account', 'account');

        return $this->resolver->resolveParameterizedRouteTo($accountComponentName, 'code', $code);


Dependency Injector

Using dependency injector is really easy. Exemplary component using injected Repository class

<?php namespace Acme\Plugin\Components;

use Cms\Classes\ComponentBase;
use Keios\Apparatus\Contracts\NeedsDependencies;
use Acme\Plugin\Classes\WebsiteRepository;

 * Class AcmeComponent
 * @package Acme\Plugin\Components
class AcmeComponent extends ComponentBase implements NeedsDependencies

     * @return array
    public function componentDetails()
        return [
            'name'        => 'Acme Component',
            'description' => 'No description...',

     * @return array
    public function defineProperties()
        return [];

     * @var RepositoryInterface
    protected $recordRepository;

     * @param WebsiteRepository $websiteRepository
    public function injectWebsiteRepository(WebsiteRepository $websiteRepository)
        $this->recordRepository = $websiteRepository;

     * Setup page variables
    public function onRun()
        $this->page['records'] = $this->recordRepository->getAll();

Backend Injector

Allows you to inject js, css and handlers into controllers from boot method of your Plugin.php

This is useful when you extend one controller with another.


public function boot(){
    $injector = $this->app->make('apparatus.backend.injector');

    $someController = new SomeController();

    $injector->addAjaxHandler('onGetMessages', [$someController, 'onGetMessages']);
    $injector->addAjaxHandler('onPostMessage', [$someController, 'onPostMessage']);
    $injector->addAjaxHandler('onGetTemplate', [$someController, 'onGetTemplate']);

Scenario Factory

[work in progress]


Optimize command

Jun 15, 2017


First version of Apparatus

Dec 18, 2016