Tempest is still a work in progress . Visit our GitHub or Discord

Standalone Components

Many Tempest components can be installed as standalone packages in existing or new projects: tempest/console , tempest/http , tempest/event-bus , tempest/debug , tempest/command-bus , etc.

A note up front : since Tempest is still in its early stages, some components depend on tempest/core , which shouldn't. There's a lot of work to be done to make components like tempest/mapper truly independent.

tempest/console

composer require tempest/console

tempest/console ships with a built-in binary:

./vendor/bin/tempest

Tempest

/* … */

Or you can manually boot the console application like so:

<?php

use \Tempest\Console\ConsoleApplication;

require_once __DIR__ . '/vendor/autoload.php';

ConsoleApplication::boot()->run();

tempest/http

tempest/http contains all code to run a web application: router and view renderer, controllers, HTTP exception handling, view components, etc.

composer require tempest/http

Note that tempest/console is shipped with tempest/http as well so that you can manage discovery cache, static pages, debug routes, use the local dev server, etc.

You can install the necessary files with the built-in tempest console:

./vendor/bin/tempest install

Or you can manually create an index.php file in your project's public folder:

<?php
use \Tempest\Http\HttpApplication;

require_once __DIR__ . '/vendor/autoload.php';

HttpApplication::boot(
    root: __DIR__ . '/../',
)->run();

Note that the root path passed in HttpApplication::boot should point to your project's root folder.

tempest/container

tempest/container is Tempest's standalone container implementation. Note that this package doesn't provide discovery, so initializers will need to be added manually.

composer require tempest/container
$container = new Tempest\Container\GenericContainer();

$container->addInitializer(FooInitializer::class);

$foo = $container->get(Foo::class);

tempest/debug

tempest/debug provides the lw , ld and ll functions. This package is truly standalone, but when installed in a Tempest project, it will also automatically write to configured log files.

composer require tempest/debug
ld($variable);

tempest/event-bus

Tempest's event bus can be used as a standalone package, in order for event handlers to be discovered, you'll have to boot Tempest's kernel and resolve the event bus from the container:

composer require tempest/event-bus
$container = Tempest::boot();

// You can manually resolve the event bus from the container
$eventBus = $container->get(\Tempest\EventBus\EventBus::class);
$eventBus->dispatch(new MyEvent());

// Or use the `event` function, which is shipped with the package
\Tempest\event(new MyEvent());

tempest/command-bus

Tempest's event bus can be used as a standalone package, in order for event handlers to be discovered, you'll have to boot Tempest's kernel and resolve the event bus from the container:

composer require tempest/command-bus
$container = Tempest::boot();

// You can manually resolve the command bus from the container
$commandBus = $container->get(\Tempest\CommandBus\CommandBus::class);
$commandBus->dispatch(new MyCommand());

// Or use the `command` function, which is shipped with the package
\Tempest\command(new \Brendt\MyEvent());

tempest/mapper

tempest/mapper maps data between many types of sources, from arrays to objects, objects to JSON, …

composer require tempest/mapper
Tempest::boot();

$foo = map(['name' => 'Hi'])->to(Foo::class);