BOSON Help

WebView Configuration

The webview configuration class Boson\WebView\WebViewCreateInfo is optional and serves as a convenient way to define default settings for webview of main window instance.

Default User Agent

Sets a custom user agent string for the WebView.

$webviewConfig = new Boson\WebView\WebViewCreateInfo( userAgent: 'MyCustomUserAgent/1.0', );

Storage (Persistent Client Settings)

Configures persistent storage settings for the WebView.

If storage is enabled, persistent settings will be saved between different app executions, such as saved passwords, history, and other data shared across browsers.

$webviewConfig = new Boson\WebView\WebViewCreateInfo( storage: '/path/to/storage', // Defaults to false (disabled) );

The storage value can take on different types:

  • false - The storage will be disabled.

  • null - The storage will be enabled and directory will be determined automatically based on the current working directory.

  • string - The storage will be enabled and directory will be based on the passed argument.

Extra Flags

Sets additional WebView configuration flags.

$webviewConfig = new Boson\WebView\WebViewCreateInfo( flags: [ 'enable-javascript' => false, ], );

These are additional platform-dependent launch flags and their behavior may differ on different platforms.

For WebView2 list of all available flags can be found on MSDN and chromium.org

$webviewConfig = new Boson\WebView\WebViewCreateInfo(flags: [ '--disable-features' => ['feature1', 'feature2'], '--do-something', ]);

For WebkitGTK list of all available flags can be found at webkitgtk.org

$webviewConfig = new Boson\WebView\WebViewCreateInfo(flags: [ 'enable-javascript' => false, ]);

For WKWebView list of all available flags can be found at developer.apple.com

$webviewConfig = new Boson\WebView\WebViewCreateInfo(flags: [ 'upgradeKnownHostsToHTTPS' => true, 'defaultWebpagePreferences.allowsContentJavaScript' => false, 'preferences.minimumFontSize' => 10, 'applicationNameForUserAgent' => 'Boson', ]);

Context Menu

Controls whether the default context menu (right mouse button) is enabled.

$webviewConfig = new Boson\WebView\WebViewCreateInfo( contextMenu: true, // Default is false );

Dev Tools

Enables or disables developer tools for the WebView.

$webviewConfig = new Boson\WebView\WebViewCreateInfo( devTools: true, // Default is null );

The developer tools settings can take one of the following values:

  • true - Enables developer tools window.

  • false - Disables developer tools window.

  • null - Depends on the application debug settings. Developer tools will be enabled if debug is enabled and vice versa.

13 May 2025