Configure a static directory
Publish a CSS file, verify its URL, and choose the right static directory mode for your build.
Publish one file
mkdir -p public/assets
printf 'body { color: navy; }\n' > public/assets/app.cssChoose one mode below. Save its profile as m4w.json, start the server and run the test in a second terminal. Stop the server before trying another mode.
manifest
List each published file in the manifest. Keep that build immutable while workers serve it. Deploy a new directory and manifest together, then restart.
printf '["app.css"]\n' > public/assets/.m4w-manifest.json{
"listen": { "port": 9000 },
"static": {
"directories": [
{
"path": "public/assets",
"prefix": "/assets",
"mode": "manifest"
}
]
}
}php vendor/mini4work/webserver/examples/server.php m4w.jsoncurl -i http://127.0.0.1:9000/assets/app.cssExpect HTTP 200 with body { color: navy; } in the response. The server matches /assets, finds app.css in the manifest and serves the file without calling your handler.
precompressed
Include the original and its encoded copies, for example ["app.css", "app.css.gz"]. Visitors still request /assets/app.css. The server uses Accept-Encoding to choose an available representation. No PHP compression extension is required.
gzip -c public/assets/app.css > public/assets/app.css.gz
printf '["app.css", "app.css.gz"]\n' > public/assets/.m4w-manifest.json{
"listen": { "port": 9000 },
"static": {
"directories": [
{
"path": "public/assets",
"prefix": "/assets",
"mode": "precompressed"
}
]
}
}php vendor/mini4work/webserver/examples/server.php m4w.jsoncurl -sSI -H 'Accept-Encoding: gzip' http://127.0.0.1:9000/assets/app.cssHTTP/1.1 200 · Content-Encoding: gzip
secure
The server looks up each file within the opened directory at request time. This mode requires enabled FFI on a supported system, including Linux 5.6+ with openat2 or macOS 13+ on supported architectures. Restart if you replace the directory itself.
{
"listen": { "port": 9000 },
"static": {
"directories": [
{
"path": "public/assets",
"prefix": "/assets",
"mode": "secure"
}
]
}
}php -d ffi.enable=true vendor/mini4work/webserver/examples/server.php m4w.jsonAdd a file while the server is running. It is available immediately without a manifest.
cp public/assets/app.css public/assets/theme.css
curl -i http://127.0.0.1:9000/assets/theme.cssHTTP/1.1 200 · body { color: navy; }