References Getting Started Getting Started Architecture Architecture Application Application Window Window WebView WebView Deployment Deployment Components Components Framework Integrations Framework Integrations Examples Examples Community Community github GitHub github Get Started arrow_up_right
Getting Started Getting Started Architecture Architecture Application Application Window Window WebView WebView Deployment Deployment Components Components Framework Integrations Framework Integrations Examples Examples Community Community

Components

HTTP URI HTTP Body Decoder HTTP Static Provider PHP Globals Provider OS Info CPU Info Assembly Weak Types Getting Started Architecture Application Window WebView Deployment Components Framework Integrations Examples Community

HTTP Static Provider

Static provider exist to serve files without execution of application code.

This component is not included by default in the boson-php/runtime and must be installed separately.

Installation

Via Composer:

composer require boson-php/http-static-provider

Requirements:

  • PHP ^8.4

Filesystem

To return static files from the filesystem, you can use specific Boson\Component\Http\Static\FilesystemStaticProvider static adapter.

use Boson\Application;
use Boson\ApplicationCreateInfo;
use Boson\Component\Http\Static\FilesystemStaticProvider;
use Boson\WebView\Api\Schemes\Event\SchemeRequestReceived;

// Create an application
$app = new Application(new ApplicationCreateInfo(
    schemes: ['static'],
));

// Create static files adapter
$static = new FilesystemStaticProvider([__DIR__ . '/public']);

$app->on(function (SchemeRequestReceived $e) use ($static): void {
    // Lookup static file and create response in
    // case of given file is available.
    $e->response = $static->findFileByRequest($e->request);
    
    if ($e->response !== null) {
        return;
    }
    
    // Do something else...
});

$app->webview->url = 'static://localhost/example/image.png';

Please note that the file search is performed by the path from the URL, excluding the host, scheme, etc. Thus, the file that will be requested at the address scheme://HOST/path/to/file.png must be located in /public/path/to/file.png.

github discord telegram Get started Documentation Contribution Guide License Release Notes BOSON PHP © 2025. All Rights Reversed.