Skip to content
Nibiru docsv0.9.2

Scaffolding Modules & Controllers

Generate controllers, modules, and plugins with the CLI.

Stable Reading time ~ 1 min Edit on GitHub
Terminal window
./nibiru -c products

Creates two files:

application/controller/productsController.php
application/view/templates/products.tpl

The controller stub:

<?php
namespace Nibiru;
use Nibiru\Adapter\Controller;
class productsController extends Controller
{
public function pageAction() {
View::assign(['title' => 'Products']);
}
public function navigationAction() {
JsonNavigation::getInstance()->loadJsonNavigationArray();
}
}

The template stub:

{include 'shared/header.tpl'}
<body>
{include file="navigation.tpl"}
<main class="container">
<h1>{$title}</h1>
</main>
{include 'shared/footer.tpl'}
</body>

Controllers are PHP files only — no JS or CSS scaffold, so you stay in control of asset wiring.

Terminal window
./nibiru -m billing

Creates:

application/module/billing/
├── billing.php
├── interfaces/billing.php
├── plugins/
├── settings/billing.ini
└── traits/

The main class implements IModule and exposes a constructor that loads the module’s registry config. Add the -g flag to include Graylog observer wiring out of the box:

Terminal window
./nibiru -m billing -g

When -g is set the scaffold imports a Graylog observer, attaches it in the constructor, and emits notify() on key state changes — so any GELF-capable Graylog server picks up module events with no extra plumbing.

A plugin lives inside a module:

Terminal window
./nibiru -p invoices -m billing

Creates application/module/billing/plugins/invoices.php:

<?php
namespace Nibiru\Module\Billing\Plugin;
use Nibiru\Module\Billing\Billing;
class Invoices extends Billing
{
public function listOpen(): array
{
return \Nibiru\Pdo::fetchAll(
'SELECT * FROM invoices WHERE status = :s ORDER BY due_date',
[':s' => 'open']
);
}
}

Plugins inherit from the module so they share its registry, settings, and observer machinery.

./nibiru -s runs after install (or after pulling a fresh checkout) to:

  • Create application/view/templates_c/ and application/view/cache/ if missing.
  • Fix permissions (writable by the web server user) on those folders.
  • Verify required PHP extensions are loaded.
  • Verify the database driver in your INI is supported by this binary build.

It’s safe to run repeatedly.

Wipes both the Smarty compile cache and the rendered HTML cache:

Terminal window
./nibiru -cache-clear

Run after a deploy when:

  • You changed .tpl files,
  • You changed [ENGINE] caching settings,
  • You modified Smarty plugins.

The cache regenerates on the next request.