Implements the Clacks-Header as per

1.2.0 2018-08-15 15:54 UTC

This package is auto-updated.

Last update: 2024-05-29 04:09:15 UTC


Build Status

As described in


composer require org_heigl/clacks-middleware



use Org_Heigl\Middleware\Clacks\Clacks;

$clacks = new Clacks();
// add $clacks to your middleware-stack

When someone sends a request that already contains an X-Clacks-Overhead header, that header is returned.

And when you want to send a different name, you can set that on the constructor like this:

use Org_Heigl\Middleware\Clacks\Clacks;

$clacks = new Clacks('Jane Doe');
// add $clacks to your middleware-stack


If you are using a PSR15 based stack you can use the ClacksMiddleware-Class instead like this:

use Org_Heigl\Middleware\Clacks\ClacksMiddleware;

$clacks = new ClacksMiddleware();
// Add $clacks to your middleware-stack

Adding $clacks to the middleware

Slim 4

use Slim\Factory\AppFactory;
use Org_Heigl\Middleware\Clacks\ClacksMiddleware;

$app = AppFactory::create();
$app->add(new ClacksMiddleware());

Slim 3

use \Slim\App;
use Org_Heigl\Middleware\Clacks\Clacks;

$app = new App();

$app->add(new Clacks());

$app->get('/', function ($request, $response, $args) {
	$response->getBody()->write(' Hello ');

	return $response;



use Laminas\Diactoros\ResponseFactory;
use Laminas\Diactoros\ServerRequestFactory;
use Laminas\HttpHandlerRunner\Emitter\SapiEmitter;
use Laminas\HttpHandlerRunner\RequestHandlerRunner;
use Laminas\Stratigility\MiddlewarePipe;
use Org_Heigl\Middleware\Clacks\ClacksMiddleware;
use function Laminas\Stratigility\middleware;

$app = new MiddlewarePipe();

// Landing page
$app->pipe(middleware(new ClacksMiddleware()));

$server = new RequestHandlerRunner(
    new SapiEmitter(),
    static function () {
        return ServerRequestFactory::fromGlobals();
    static function (\Throwable $e) {
        $response = (new ResponseFactory())->createResponse(500);
            'An error occurred: %s',
        return $response;