Skip to content

Commit 8e68910

Browse files
committed
Add documentation for FrankenPHP in classic and worker modes
1 parent c789de6 commit 8e68910

File tree

4 files changed

+73
-1
lines changed

4 files changed

+73
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ We support Debian >= 11 and Ubuntu >= 20.04.
6565
You can run on Debian 10, by doing this setup before install: [Debian10 setup](./docs/debian10.md)
6666

6767
#### Deployment setup
68-
- [Caddy & PHP-FPM](./docs/caddy.md)
68+
- [Caddy & PHP-FPM](./docs/caddy-php-fpm.md)
6969
- [Apache mod_php](./docs/apache-mod-php.md)
70+
- [FrannkenPHP classic](./docs/caddy-frankenphp-classic.md)
71+
- [FrannkenPHP worker](./docs/caddy-frankenphp-worker.md)
7072

7173
#### Managed platforms
7274
- [Laravel Forge](./docs/laravel-forge.md)

docs/caddy-frankenphp-classic.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# FrankenPHP (Classic Mode)
2+
3+
1. Pass the Aikido environment variables in your `Caddyfile`
4+
5+
`Caddyfile`
6+
```
7+
example.com {
8+
root * /var/www/html/public
9+
10+
php_server {
11+
env AIKIDO_TOKEN "AIK_RUNTIME_...."
12+
env AIKIDO_BLOCK "True"
13+
}
14+
15+
file_server
16+
}
17+
```
18+
19+
You can get your token from the [Aikido Security Dashboard](https://help.aikido.dev/doc/creating-an-aikido-zen-firewall-token/doc6vRJNzC4u).
20+
21+
2. Start FrankenPHP
22+
23+
`frankenphp run --config Caddyfile`

docs/caddy-frankenphp-worker.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# FrankenPHP (Worker Mode)
2+
3+
1. Pass the Aikido environment variables to FrankenPHP in your `Caddyfile` and configure the worker
4+
5+
`Caddyfile`
6+
```
7+
example.com {
8+
root * /var/www/html/public
9+
10+
php_server {
11+
env AIKIDO_TOKEN "AIK_RUNTIME_...."
12+
env AIKIDO_BLOCK "True"
13+
worker {
14+
file /var/www/html/public/index.php
15+
num 4
16+
}
17+
}
18+
19+
file_server
20+
}
21+
```
22+
23+
You can get your token from the [Aikido Security Dashboard](https://help.aikido.dev/doc/creating-an-aikido-zen-firewall-token/doc6vRJNzC4u).
24+
25+
2. Call `\aikido\worker_rinit()` and `\aikido\worker_rshutdown()` in your worker script
26+
27+
Wrap your request handler with these calls to ensure Aikido processes each request.
28+
29+
`public/index.php`
30+
```php
31+
<?php
32+
33+
require __DIR__ . '/../vendor/autoload.php';
34+
$app = require_once __DIR__ . '/../bootstrap/app.php';
35+
36+
while (frankenphp_handle_request(function () use ($app) {
37+
\aikido\worker_rinit();
38+
// Your application logic
39+
\aikido\worker_rshutdown();
40+
})) {
41+
// keep looping
42+
}
43+
```
44+
45+
3. Start FrankenPHP
46+
47+
`frankenphp run --config Caddyfile`
File renamed without changes.

0 commit comments

Comments
 (0)