{"id":27719425,"url":"https://github.com/bosonphp/runtime","last_synced_at":"2025-04-27T07:47:40.560Z","repository":{"id":239075151,"uuid":"798442695","full_name":"BosonPHP/runtime","owner":"BosonPHP","description":"PHP WebView runtime","archived":false,"fork":false,"pushed_at":"2025-04-25T02:49:21.000Z","size":7693,"stargazers_count":44,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-27T07:47:25.574Z","etag":null,"topics":["bridge","browser","html","interface","native","php","php84","render","webview"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BosonPHP.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-05-09T19:35:12.000Z","updated_at":"2025-04-25T20:31:10.000Z","dependencies_parsed_at":"2024-10-03T17:08:02.436Z","dependency_job_id":"810bf2a8-5583-4904-ae89-d5272c1187b4","html_url":"https://github.com/BosonPHP/runtime","commit_stats":null,"previous_names":["serafimarts/winui"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BosonPHP%2Fruntime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BosonPHP%2Fruntime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BosonPHP%2Fruntime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BosonPHP%2Fruntime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BosonPHP","download_url":"https://codeload.github.com/BosonPHP/runtime/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251106449,"owners_count":21537168,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bridge","browser","html","interface","native","php","php84","render","webview"],"created_at":"2025-04-27T07:47:39.852Z","updated_at":"2025-04-27T07:47:40.547Z","avatar_url":"https://github.com/BosonPHP.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"https://github.com/BosonPHP/runtime\"\u003e\n    \u003cimg align=\"center\" src=\"https://github.com/user-attachments/assets/169b6bf1-4644-4873-ac4e-6448b36dc2a5\" /\u003e\n\u003c/a\u003e\n\n---\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://packagist.org/packages/boson-php/runtime\"\u003e\u003cimg src=\"https://poser.pugx.org/boson-php/runtime/require/php?style=for-the-badge\" alt=\"PHP 8.4+\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/boson-php/runtime\"\u003e\u003cimg src=\"https://poser.pugx.org/boson-php/runtime/version?style=for-the-badge\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/boson-php/runtime\"\u003e\u003cimg src=\"https://poser.pugx.org/boson-php/runtime/v/unstable?style=for-the-badge\" alt=\"Latest Unstable Version\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://raw.githubusercontent.com/BosonPHP/runtime/blob/master/LICENSE\"\u003e\u003cimg src=\"https://poser.pugx.org/boson-php/runtime/license?style=for-the-badge\" alt=\"License MIT\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/xepozz/meta-storm-idea-plugin\"\u003e\u003cimg src=\"https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e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/BosonPHP/runtime/actions/workflows/tests.yml\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/BosonPHP/runtime/tests.yml?label=Tests\u0026style=flat-square\u0026logo=unpkg\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/BosonPHP/runtime/actions/workflows/codestyle.yml\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/BosonPHP/runtime/codestyle.yml?label=PER-2+CodeStyle\u0026style=flat-square\u0026logo=telegraph\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/BosonPHP/runtime/actions/workflows/static-analysis.yml\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/BosonPHP/runtime/static-analysis.yml?label=PHPStan\u0026style=flat-square\u0026logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAGb0lEQVR42u1Xe1BUZRS/y4Kg8oiR3FCCBUySESZBRCiaBnmEsOzeSzsg+KxYYO9dEEftNRqZjx40FRZkTpqmOz5S2LsXlEZBciatkQnHDGYaGdFy1EpGMHl/p/PdFlt2rk5O+J9n5nA/vtf5ned3lnlISpRhafBlLRLHCtJGVrB/ZBDsaw2lUqzReGAC46DstTYfnSCGUjaaDvgxACo6j3vUenNdImeRXqdnWV5az5rrnzeZznj8J+E5Ftsclhf3s4J4CS/oRx5Bvon8ZU65FGYQxAwcf85a7CeRz+C41THejueydCZ7AAK34nwv3kHP/oUKdOL4K7258fF7Cud427O48RQeGkIGJ77N8fZqlrcfRP4d/x90WQfHXLeBt9dTrSlwl3V65ynWLM1SEA2qbNQckbe4Xmww10Hmy3shid0CMcmlEJtSDsl5VZBdfAgMvI3uuR+moJqN6LaxmpsOBeLCDmTifCB92RcQmbAUJvtqALc5sQr8p86gYBCcFdBq9wOin7NQax6ewlB6rqLZHf23FP10y3lj6uJtEBg2HxiVCtzd3SEwMBCio6Nh9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6zlhsn06bEhwX4NyfCvuGEeRpTmh4mkG68yDpyuzB9EUcjU5awbAgncPlAeSdAQER0zCndzqVbeXC4qDsMpvGEYBXRnsDx4N3Auf1FCTjTIaVtY/QTmd0I8bBVm1kejEubUfO01vqImn3c49X7qpeqI9inIgtbpxK3YrKfIJCt+OeV2nfUVFR4ca4EkVENyA7gkYcMfB1R5MMmxZ7ez/2KF5SSN1yV+158UPsJT0ZBcI2bRLtIXGoYu5FerOUiJe1OfsL3XEWH43l2KS+iJF9+S4FpcNgsc+j8cT8H4o1bfPg/qkLt50uJ1RzdMsGg0UqwfEN114Pwb1CtWTGg+Y9U5ClK9x7xUWI7BI5VQVp0AVcQ3bZkQhmnEgdHhKyNSZe16crtBIlc7sIb6cRLft2PCgoKGjijBDtjrAQ7a3EdMsxzIRflAFIhPb6mHYmYwX+WBlPQgskhgVryyJCQyNyBLsBQdQ6fgsQhyt6MSOOsWZ7gbH8wETmgRKAijatNL8Ngm0xx4tLcsps0Wzx4al0jXlI40B/A3pa144MDtSgAAAAAElFTkSuQmCC\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://t.me/boson_php\"\u003e\u003cimg src=\"https://img.shields.io/static/v1?label=\u0026message=Join+To+Community\u0026color=24A1DE\u0026style=for-the-badge\u0026logo=telegram\u0026logoColor=white\" alt=\"Telegram\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nWhy Boson? Because it's not an [Electron](https://www.electronjs.org)! \nAnd much easier than that =)\n\n\u003e Also, this repository contains included high level PHP bindings \n\u003e [for Saucer v6.0](https://github.com/saucer/saucer).\n\n- [Simple Example](#simple-example)\n- [Requirements](#requirements)\n  - [Windows](#windows)\n  - [Linux \u0026 BSD](#linux-and-bsd)\n  - [MacOS](#macos)\n- [Installation](#installation)\n- [Usage](#usage)\n  - **Application**\n    - [Configuration](#application-configuration)\n    - [Launching](#application-launching)\n    - [Autorun](#application-autorun)\n    - [Quit](#application-quit) \n  - **Window**\n    - [Window Title](#window-title)\n    - [Window Size](#window-size)\n    - [Window Resizing](#window-resizing)\n    - [Window Max Size](#window-max-size)\n    - [Window Min Size](#window-min-size)\n    - [Window Decorations](#window-decorations)\n  - **WebView**\n    - [HTML Content](#webview-html-content)\n    - [Navigation to URL](#webview-url-navigation)\n    - [Navigation URL info](#webview-url-info)\n    - [Custom Protocols](#webview-custom-protocols)\n    - **JavaScript** \n      - [Scripts](#webview-scripts)\n      - [Code Evaluation](#webview-code-evaluation)\n      - [Creating Functions](#webview-function-bindings)\n      - [Code Requests](#webview-requests)\n  - **Events**\n    - [Events and Intentions](#events-and-intentions)\n  - **Misc**\n    - [Debug Mode](#debug-mode)\n    - [Custom Library](#custom-library)\n\n## Simple Example\n\n```php\nuse Boson\\Application;\n\n$app = new Application();\n\n$app-\u003ewebview-\u003ehtml = \u003c\u003c\u003c'HTML'\n    \u003cbutton onclick=\"foo('HELLO');\"\u003eHello\u003c/button\u003e\n    HTML;\n\n$app-\u003ewebview-\u003ebind('foo', function (string $message): void {\n    var_dump($message);\n});\n\n$app-\u003erun();\n```\n\n## Requirements\n\n- PHP ^8.4\n  - ext-ffi\n\n| Platform | X86 | AMD64 | ARM64 | Technologies                                                                                                                                                        |\n|----------|-----|-------|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Windows  | ✓   | ✓     | ✖     | [Windows API](https://docs.microsoft.com/en-us/windows/win32/apiindex/windows-api-list), [WebView2](https://developer.microsoft.com/en-us/microsoft-edge/webview2/) |\n| Linux    | ✓   | ✓     | ✓     | [GTK](https://gtk.org/), [WebKitGTK](https://webkitgtk.org/), [Qt5/Qt6](https://github.com/qt/qtwebkit)                                                             |\n| macOS    | ✓   | ✓     | ✓     | Cocoa, [WebKit](https://webkit.org/)                                                                                                                                |\n\n\u003e At the moment, all binaries are supplied [together with the library](./bin). \n\u003e In future versions, a separate platform-dependent installation of \n\u003e assemblies from [the GitHub Actions CI](https://github.com/BosonPHP/frontend/actions/workflows/build.yml) \n\u003e is planned.\n\n### Windows\n\nRequires Windows 10 or higher.\n\nEnd-users must have the [WebView2 runtime](https://developer.microsoft.com/en-us/microsoft-edge/webview2/) \ninstalled on their system for any version of Windows before Windows 11.\n\n### MacOS\n\nIt appears that no additional dependencies are required.\n\n### Linux and BSD\n\nSupports both [WebKitGTK](https://webkitgtk.org/) and [Qt5](https://github.com/qt/qtwebkit) \nas well as [Qt6](https://github.com/qt/qtwebkit) on Linux.\n\nThe default backend is WebKitGtk:\n- Debian: `apt install libgtk-4-1 libwebkitgtk-6.0-4`\n- Fedora: `dnf install gtk4 webkitgtk6.0`\n- FreeBSD: `pkg install webkit2-gtk4`\n\nYou can download other assemblies separately from [GitHub Actions](https://github.com/BosonPHP/runtime/actions/workflows/build.yml).\nAutomatic detection and installation of dependencies is not supported yet.\n\n## Installation\n\nBoson package is available as Composer repository and can \nbe installed using the following command in a root of your project:\n\n```bash\n$ composer require boson-php/runtime\n```\n\n## Usage\n\n\u003e This documentation corresponds to the latest release (see https://github.com/BosonPHP/runtime/tags). \n\u003e Behavior and code in the `master` branch may differ from what is shown below.\n\n## Application Configuration\n\nAn application configuration is built on the basis of the DTO hierarchy, \nwhich reflects the application hierarchy.\n\n```\nApplicationCreateInfo\n  // ... application configs\n\n  window: WindowCreateInfo\n    // ... window configs\n\n    webview: WebViewCreateInfo\n    // ... webview configs\n```\n\nIn the PHP code it might look like this:\n\n```php\nuse Boson\\ApplicationCreateInfo;\nuse Boson\\WebView\\WebViewCreateInfo;\nuse Boson\\Window\\WindowCreateInfo;\n\n$config = new ApplicationCreateInfo(\n    debug: false,\n    window: new WindowCreateInfo(\n        title: 'Hello World!',\n        width: 640,\n        height: 480,\n        webview: new WebViewCreateInfo(\n            html: '\u003ch1\u003eHello!\u003c/h1\u003e',\n            contextMenu: false,\n        ),\n    ),\n);\n```\n\nThe configuration is passed to the application itself \nand can be optional.\n\n```php\nuse Boson\\Application;\nuse Boson\\ApplicationCreateInfo;\n\n// Create an application\n$app = new Application();\n\n// Create an application with configuration\n$appWithConfig = new Application(new ApplicationCreateInfo(\n    debug: false,\n));\n```\n\n\n## Application Launching\n\nTo start the application, you must call the `run()` method.\n\n```php\n$app = new Boson\\Application();\n\n$app-\u003erun();\n```\n\nLaunching an application blocks the execution thread,\nmeaning that no further code will be executed until the\napplication is stopped.\n\n```php\n$app = new Boson\\Application();\n\n$app-\u003erun();\n\necho 'This code DOES NOT execute until the application is stopped!';\n```\n\n\u003e In most cases, explicit `run()` invocation is not required, as the \n\u003e [autorun](#application-autorun) option is enabled by default.\n\n## Application Autorun\n\nBy default, the application is automatically launched after creation (delayed, \nnot immediately), even if you do not call the `run()` method yourself. \nThis is because the autostart option is enabled (defined as `true`) by default.\n\nIf you do not need the application to start automatically, \nthen this option should be disabled (set to `false`).\n\n```php\nuse Boson\\Application;\nuse Boson\\ApplicationCreateInfo;\n\n$app = new Application(new ApplicationCreateInfo(\n    autorun: false,\n));\n```\n\n\n## Application Quit\n\nTo stop the application, you should call the `quit()` method.\n\n```php\n$app = new Boson\\Application();\n\n/// ... do smth\n\n$app-\u003equit();\n```\n\nSince exit (according to the logic of work) occurs after the application is \nlaunched, and launching blocks the thread, it makes sense for the application\nto terminate after any event is fired.\n\n```php\nuse Boson\\Application;\nuse Boson\\Window\\Event\\WindowMinimized;\n\n$app = new Application();\n\n// The application will exit after minimizing.\n$app-\u003eevents-\u003eaddEventListener(WindowMinimized::class, function () use ($app) {\n    $app-\u003equit();\n});\n```\n\nIt is also worth keeping in mind that the application may close \nautomatically after ALL windows are closed. To disable this behavior, \nyou should set the `quitOnClose` application config.\n\n```php\nuse Boson\\Application;\nuse Boson\\ApplicationCreateInfo;\n\n$appWithConfig = new Application(new ApplicationCreateInfo(\n    // Disables app quit when all windows are has been closed\n    quitOnClose: false,\n));\n```\n\n\n### Window Title\n\nTo get or update the title, you should change the `$title` property\n\n```php\n$app = new Boson\\Application();\n\n$app-\u003ewebview-\u003etitle = 'New Title';\n\necho 'Current Title: ' . $app-\u003ewebview-\u003etitle;\n```\n\nOr set title from configuration\n\n```php\n$app = new Boson\\Application(\n    info: new \\Boson\\ApplicationCreateInfo(\n        window: new Boson\\Window\\WindowCreateInfo(\n            title: 'New Title',\n        ),\n    ),\n);\n```\n\n\n### Window Size\n\nTo obtain window size, use the `$size` property.\n\n```php\n$app = new Boson\\Application();\n\necho $app-\u003ewindow-\u003esize; // Size(640 × 480)\n\necho $app-\u003ewindow-\u003esize-\u003ewidth; // int(640)\necho $app-\u003ewindow-\u003esize-\u003eheight; // int(480)\n```\n\nYou also may set default window size via configuration.\n\n```php\n$app = new Boson\\Application(\n    info: new \\Boson\\ApplicationCreateInfo(\n        window: new Boson\\Window\\WindowCreateInfo(\n            width: 640,\n            height: 480,\n        ),\n    ),\n);\n```\n\n\n### Window Resizing\n\nTo change the size, use the `$size` property.\n\n```php\n$app = new Boson\\Application();\n\n// Update window size to 640×480\n$app-\u003ewindow-\u003esize-\u003eupdate(640, 480);\n\n// Or set the dimensions explicitly using new Size object\n$app-\u003ewindow-\u003esize = new \\Boson\\Window\\Size(640, 480);\n```\n\nIn addition, each window size can also be changed separately.\n\n```php\n$app = new Boson\\Application();\n\n$app-\u003ewindow-\u003esize-\u003ewidth = 640;\n$app-\u003ewindow-\u003esize-\u003eheight = 480;\n```\n\nTo disable the ability to resize a window, pass the appropriate \n`resizable` window configuration option.\n\n```php\n$app = new Boson\\Application(\n    info: new \\Boson\\ApplicationCreateInfo(\n        window: new Boson\\Window\\WindowCreateInfo(\n            resizable: false,\n        ),\n    ),\n);\n```\n\n\n### Window Max Size\n\nTo specify the maximum window size, use the `$max` property. The behavior of \nthe property is identical to the `$size` property [described above](#window-size).\n\n```php\n$app = new Boson\\Application();\n\necho $app-\u003ewindow-\u003emax; // Will display the maximum allowed window size\n\n$app-\u003ewindow-\u003emax-\u003eupdate(1024, 768);\n```\n\n\n### Window Min Size\n\nTo specify the maximum window size, use the `$min` property. The behavior of\nthe property is identical to the `$size` property [described above](#window-size).\n\n```php\n$app = new Boson\\Application();\n\necho $app-\u003ewindow-\u003emin; // Will display the minimum allowed window size\n\n$app-\u003ewindow-\u003emin-\u003eupdate(1024, 768);\n```\n\n\n### Window Decorations\n\nYou can change the standard window\\`s title bar, minimize, maximize and close \nbuttons via `Boson\\Window\\WindowDecoration` enum.\n\n```php\n$app = new Boson\\Application();\n\n// Sets default window behaviour\n$app-\u003ewindow-\u003edecoration = Boson\\Window\\WindowDecoration::Default;\n\n// Enable dark mode\n$app-\u003ewindow-\u003edecoration = Boson\\Window\\WindowDecoration::DarkMode;\n\n// Disable window decorations\n$app-\u003ewindow-\u003edecoration = Boson\\Window\\WindowDecoration::Frameless;\n\n// Disable decorations and make window transparent\n$app-\u003ewindow-\u003edecoration = Boson\\Window\\WindowDecoration::Transparent;\n```\n\nOr via configuration options.\n\n```php\n$app = new Boson\\Application(\n    info: new \\Boson\\ApplicationCreateInfo(\n        window: new Boson\\Window\\WindowCreateInfo(\n            decoration: Boson\\Window\\WindowDecoration::Frameless,\n        ),\n    ),\n);\n```\n\n| Enum Case   | Controls | Dark Mode | Transparency |\n|-------------|----------|-----------|--------------|\n| Default     | ✓        | ✗         | ✗            |\n| DarkMode    | ✓        | ✓         | ✗            |\n| Frameless   | ✗        | ✗         | ✗            |\n| Transparent | ✗        | ✗         | ✓            |\n\n\nPlease note that by disabling the standard title bar and buttons you will not\nbe able to control the window (moving and resizing), but you can implement \nthis behavior yourself using HTML attributes.\n\n```php\n$app = new Boson\\Application(\n    info: new \\Boson\\ApplicationCreateInfo(\n        window: new Boson\\Window\\WindowCreateInfo(\n            decorated: false,\n            webview: new \\Boson\\WebView\\WebViewCreateInfo(\n                html: \u003c\u003c\u003c'HTML'\n                    \u003cdiv data-webview-drag\u003e\n                        By dragging this element you can move the window\n\n                        \u003cbutton data-webview-ignore\u003enon-draggable button\u003c/button\u003e\n                    \u003c/div\u003e\n                    \n                    \u003chr /\u003e\n                    \n                    \u003cdiv data-webview-resize=\"br\"\u003e\n                        By dragging this element you can resize the window\n                    \u003c/div\u003e\n                    HTML\n            )\n        ),\n    ),\n);\n```\n\n- The `data-webview-drag` attribute defines the area by dragging \n  which you can move the window.\n- The `data-webview-resize` attribute defines the area by dragging\n  which you can resize the window.\n  - An `t` attribute's value means the ability to resize vertically, top of the window. \n  - An `b` attribute's value means the ability to resize vertically, bottom of the window. \n  - An `r` attribute's value means the ability to resize horizontally, right of the window. \n  - An `l` attribute's value means the ability to resize horizontally, left of the window.\n  - Using combinations such as `tl`, `tr`, `bl` and `br` allows you to specify \n    simultaneous resizing of the window vertically and horizontally.\n- The `data-webview-ignore` attribute disables drag or resize behaviour for\n  the element and children.\n\n\n### WebView HTML Content\n\nTo set the content, you should use the `$html` property\n\n```php\n$app = new Boson\\Application();\n\n$app-\u003ewebview-\u003ehtml = '\u003cbutton\u003eDo Not Click Me!\u003c/button\u003e';\n```\n\nOr set html content from configuration\n\n```php\n$app = new Boson\\Application(\n    window: new Boson\\Window\\WindowCreateInfo(\n        webview: new Boson\\WebView\\WebViewCreateInfo(\n            html: '\u003cbutton\u003eDo Not Click Me!\u003c/button\u003e',\n        ),\n    ),\n);\n```\n\nPlease note that reading this property is NOT possible. If you need to\nread the contents, use the [data retrieval method](#code-requests).\n\n```php\nuse Boson\\Application;\nuse Boson\\WebView\\Event\\WebViewDomReady;\n\n$app = new Application();\n\n$app-\u003ewebview-\u003ehtml = '\u003cbutton\u003eDo Not Click Me!\u003c/button\u003e';\n\n$app-\u003eevents-\u003eaddEventListener(WebViewDomReady::class, function () use ($app) {\n    $html = $app-\u003ewebview-\u003erequest('document.body.innerHTML');\n    \n    var_dump($html);\n});\n```\n\n\n### WebView URL Navigation\n\nTo load content from the URL, you should use the `$url` property\n\n```php\n$app = new Boson\\Application();\n\n$app-\u003ewebview-\u003eurl = 'https://github.com/BosonPHP';\n```\n\nOr set URL from configuration\n\n```php\n$app = new Boson\\Application(\n    window: new Boson\\Window\\WindowCreateInfo(\n        webview: new Boson\\WebView\\URLWebViewCreateInfo(\n            url: 'https://github.com/BosonPHP',\n        ),\n    ),\n);\n```\n\n\n### WebView URL Info\n\nIn addition to navigation to the specified URL address, it is also possible \nto obtain information about the URL.\n\n```php\n$app = new Boson\\Application();\n\n$app-\u003ewebview-\u003eurl = 'https://github.com/BosonPHP';\n\necho 'URL: ' . $app-\u003ewebview-\u003eurl . \"\\n\"; // string(\"about:blank\")\n\n$app-\u003eevents-\u003eaddEventListener(WebViewNavigated::class, function () use ($app) {\n    echo 'URL: ' . $app-\u003ewebview-\u003eurl . \"\\n\"; // string(\"https://github.com/BosonPHP\")\n});\n```\n\nIn addition, you can get separate information about the URL parts.\n\n```php\n$app = new Boson\\Application();\n\n$app-\u003ewebview-\u003eurl = 'https://github.com/BosonPHP';\n\n$app-\u003eevents-\u003eaddEventListener(WebViewNavigated::class, function () use ($app) {\n    echo 'Scheme: ' . $app-\u003ewebview-\u003eurl-\u003escheme . \"\\n\"; // string(\"https\")\n    echo 'Host:   ' . $app-\u003ewebview-\u003eurl-\u003ehost . \"\\n\";   // string(\"github.com\")\n    echo 'Path:   ' . $app-\u003ewebview-\u003eurl-\u003epath . \"\\n\";   // string(\"/BosonPHP\")\n});\n```\n\n\n### WebView Custom Protocols\n\nYou can register custom scheme/protocols and intercept standard one.\n\nTo enable processing of specific protocols, you should specify \nthem in the list of schemes.\n\n```php\n$app = new Boson\\Application(new Boson\\ApplicationCreateInfo(\n    // List of handling \"https\" protocol\n    schemes: [ 'https' ],\n));\n\n$app-\u003ewebview-\u003eurl = 'https://hello.world/';\n```\n\nAfter enabling the interception of all the necessary protocols (in this \ncase, `https`), you can start catching the corresponding events of sending \nrequests to this protocol (to this scheme).\n\n```php\nuse \\Boson\\WebView\\Event\\WebViewRequest;\n\n$app = new Boson\\Application(new Boson\\ApplicationCreateInfo(\n    // List of middleware for \"https\" protocol\n    schemes: [ 'https' ],\n));\n\n$app-\u003eevents-\u003eaddEventListener(WebViewRequest::class, function (WebViewRequest $e) {\n    echo \\sprintf(\"%s %s\\r\\n\", $e-\u003erequest-\u003emethod, $e-\u003erequest-\u003eurl);\n    foreach ($e-\u003erequest-\u003eheaders as $header =\u003e $value) {\n        echo \\sprintf(\"%s: %s\\r\\n\", $header, $value);\n    }\n    echo \\sprintf(\"\\r\\n\\r\\n%s\", $e-\u003erequest-\u003ebody);\n    \n    //\n    // Result may looks like:\n    //\n    // GET https://hello.world/\n    // accept: text/html,application/xhtml+xml,application/xml;q=0.9,etc...\n    // upgrade-insecure-requests: 1\n    // user-agent: Mozilla/5.0 etc...\n    // sec-ch-ua: \"Microsoft Edge WebView2\";v=\"135\", etc...\n    // sec-ch-ua-mobile: ?0\n    // sec-ch-ua-platform: \"Windows\"\n    //\n});\n\n$app-\u003ewebview-\u003eurl = 'https://hello.world/';\n```\n\nIn that case, if you need to block a request to a specified URL, \nyou can cancel it.\n\n```php\n$app-\u003eevents-\u003eaddEventListener(WebViewRequest::class, function (WebViewRequest $e) {\n    $e-\u003ecancel();\n});\n```\n\nIn addition to canceling a request, you can also simulate a \nresponse from a resource.\n\n```php\n$app-\u003eevents-\u003eaddEventListener(WebViewRequest::class, function (WebViewRequest $e) {\n    $e-\u003eresponse = new \\Boson\\Http\\Response(\n        body: 'Hello World!',\n    );\n});\n```\n\nOr a more complex response example:\n\n```php\n$app-\u003eevents-\u003eaddEventListener(WebViewRequest::class, function (WebViewRequest $e) {\n    $e-\u003eresponse = new \\Boson\\Http\\Response(\n        body: \\json_encode(['error' =\u003e 'Something went wrong']),\n        headers: ['content-type' =\u003e 'application/json'],\n        status: \\Boson\\Http\\StatusCode::NotFound,\n    );\n});\n```\n\n\n### WebView Code Evaluation\n\nYou can execute arbitrary code directly on current WebView\n\n```php\n$app = new Boson\\Application();\n\n// Load empty page\n$app-\u003ewebview-\u003ehtml = '';\n// Evaluate JS code on this page\n$app-\u003ewebview-\u003eeval('document.write(\"Hello World!\")');\n```\n\n\n### WebView Scripts\n\nYou can register a JavaScript code that will be applied to any page.\n\n```php\n$app = new Boson\\Application();\n\n$app-\u003ewebview-\u003escripts-\u003eadd(\u003c\u003c\u003c'JS'\n    alert('hello');\n    JS);\n```\n\nOr set scripts from configuration\n\n```php\n$app = new Boson\\Application(\n    window: new Boson\\Window\\WindowCreateInfo(\n        webview: new Boson\\WebView\\WebViewCreateInfo(\n            scripts: [\u003c\u003c\u003c'JS'\n                alert('hello');\n                JS],\n        ),\n    ),\n);\n```\n\nIt is worth noting that adding code is available in several options.\n\n```php\n$app = new Boson\\Application();\n\n// \"This code will be executed BEFORE the page loads: undefined\"\n$app-\u003ewebview-\u003escripts-\u003epreload(\u003c\u003c\u003c'JS'\n    console.log('This code will be executed BEFORE the page loads: ' + document?.body?.innerHTML);\n    JS);\n\n// \"This code will be executed AFTER the page loads: \u003cb\u003ehello\u003c/b\u003e\"\n$app-\u003ewebview-\u003escripts-\u003eadd(\u003c\u003c\u003c'JS'\n    console.log('This code will be executed AFTER the page loads: ' + document?.body?.innerHTML);\n    JS);\n    \n$app-\u003ewebview-\u003ehtml = '\u003cb\u003ehello\u003c/b\u003e';\n```\n\n\n### WebView Function Bindings\n\nYou can create a function that can be called directly from WebView\n\n```php\n$app = new Boson\\Application();\n\n$app-\u003ewebview-\u003ebind('foo', function () { \n    var_dump('Executed!');\n});\n```\n\nOr set functions list from configuration\n\n```php\n$app = new Boson\\Application(\n    window: new Boson\\Window\\WindowCreateInfo(\n        webview: new Boson\\WebView\\WebViewCreateInfo(\n            functions: ['foo' =\u003e function () { \n                var_dump('Executed!');\n            }],\n        ),\n    ),\n);\n```\n\n\n### WebView Requests\n\nYou can directly get data from WebView context.\n\n```php\n$app = new Boson\\Application();\n\n$app-\u003eevents-\u003eaddEventListener(WebViewDomReady::class, function () use ($app) {\n    var_dump($app-\u003ewebview-\u003erequest('document.location')); \n    // array:10 [\n    //   \"ancestorOrigins\" =\u003e []\n    //   \"href\" =\u003e \"https://nesk.me/\"\n    //   \"origin\" =\u003e \"https://nesk.me\"\n    //   \"protocol\" =\u003e \"https:\"\n    //   \"host\" =\u003e \"nesk.me\"\n    //   \"hostname\" =\u003e \"nesk.me\"\n    //   \"port\" =\u003e \"\"\n    //   \"pathname\" =\u003e \"/\"\n    //   \"search\" =\u003e \"\"\n    //   \"hash\" =\u003e \"\"\n    // ]\n});\n\n$app-\u003ewebview-\u003eurl = 'https://nesk.me';\n```\n\nPlease note that the request CAN NOT be processed if the \napplication is not running.\n\n```php\n$app = new Boson\\Application();\n\nvar_dump($app-\u003ewebview-\u003erequest('document.location'));\n//\n// Uncaught Boson\\WebView\\Requests\\Exception\\UnprocessableRequestException:\n//      Request \"document.location\" could not be processed\n//      because application is not running\n//\n```\n\n\n### Events and Intentions\n\nAny event is a fact. Events can not be changed or rejected. Unlike events, \nan intent is an attempt by the application or any of its components to do \nsomething. Any intent can be rejected or modified.\n\nTo subscribe to events and intents, the `$events` field is used.\n\n```php\nuse Boson\\WebView\\Event\\WebViewNavigating;\nuse Boson\\WebView\\Event\\WebViewNavigated;\n\n$app = new Boson\\Application();\n\n$app-\u003eevents-\u003eaddEventListener(WebViewNavigating::class, function (WebViewNavigating $intention): void {\n    echo 'Try to move on URL: ' . $intention-\u003eurl . \"\\n\";\n\n    // Randomly block navigating to another URL\n    if (\\random_int(0, 1)) {\n        $intention-\u003ecancel();\n    }\n});\n\n$app-\u003eevents-\u003eaddEventListener(WebViewNavigated::class, function (WebViewNavigated $event): void {\n    echo 'Navigated to URL: ' . $event-\u003eurl . \"\\n\";\n});\n\n$app-\u003ewebview-\u003eurl = 'https://nesk.me';\n```\n\n\n### Debug Mode\n\nTo enable debug mode, you should define the `debug: ?bool` \nargument of the `Application` instance.\n\n```php\n$app = new Boson\\Application(\n    // true  - enable debug mode\n    // false - disable debug mode\n    // null  - autodetect debug mode\n    debug: true, \n);\n```\n\n\n### Custom Library\n\nTo define binary, you should define the `library: ?non-empty-string`\nargument of the `Application` instance.\n\n```php\n$app = new Boson\\Application(\n    // string - defines pathname to the library\n    // null   - autodetect library\n    library: __DIR__ . '/path/to/custom-webview.so',\n);\n```\n\n---\n\nAny questions left? You can ask them [in the chat `t.me/boson_php`](https://t.me/boson_php)!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbosonphp%2Fruntime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbosonphp%2Fruntime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbosonphp%2Fruntime/lists"}