Skip to content

Latest commit

 

History

History
48 lines (34 loc) · 1.05 KB

File metadata and controls

48 lines (34 loc) · 1.05 KB

FrankenPHP (Worker Mode)

  1. Pass the Aikido environment variables to FrankenPHP in your Caddyfile and configure the worker

Caddyfile

example.com {
    root * /var/www/html/public

    php_server {
        env AIKIDO_TOKEN "AIK_RUNTIME_...."
        env AIKIDO_BLOCK "True"
        worker {
          // your worker parameters
        }
    }

    file_server
}

You can get your token from the Aikido Security Dashboard.

  1. Call \aikido\worker_rinit() and \aikido\worker_rshutdown() in your worker script

Wrap your request handler with these calls to ensure Aikido processes each request.

public/index.php

<?php

require __DIR__ . '/../vendor/autoload.php';
$app = require_once __DIR__ . '/../bootstrap/app.php';

while (frankenphp_handle_request(function () use ($app) {
    \aikido\worker_rinit();

    // Your application logic
    
    \aikido\worker_rshutdown();
})) {
    // keep looping
}
  1. Start FrankenPHP

frankenphp run --config Caddyfile