1. Go to this page and download the library: Download serafim/boson library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
serafim / boson example snippets
useSerafim\Boson\Application;
$app = new Application();
$app->webview->html = <<<'HTML'
<button onclick="foo('HELLO');">Hello</button>
HTML;
$app->webview->bind('foo', function (string $message): void {
var_dump($message);
});
$app->run();
$app = new Serafim\Boson\Application(
window: new Serafim\Boson\Window\NewWindowCreateInfo(
title: 'New Title'
),
);
$app->run();
$app = new Serafim\Boson\Application();
$app->window->resize(640, 480);
$app->run();
$app = new Serafim\Boson\Application(
window: new Serafim\Boson\Window\NewWindowCreateInfo(
width: 640,
height: 480,
),
);
$app->run();
$app = new Serafim\Boson\Application();
$app->window->resize(640, 480, \Serafim\Boson\Window\WindowSizeHint::MaxBounds);
$app->run();
$app = new Serafim\Boson\Application();
$app->window->resize(640, 480, \Serafim\Boson\Window\WindowSizeHint::MinBounds);
$app->run();
$app = new Serafim\Boson\Application();
$app->window->resize(640, 480, \Serafim\Boson\Window\WindowSizeHint::Fixed);
$app->run();
$app = new Serafim\Boson\Application();
$app->window->darkMode = true;
$app->run();
$app = new Serafim\Boson\Application(
window: new Serafim\Boson\Window\NewWindowCreateInfo(
darkMode: true,
),
);
$app->run();
$app = new Serafim\Boson\Application();
$app->webview->html = '<button>Do Not Click Me!</button>';
$app->run();
$app = new Serafim\Boson\Application(
window: new Serafim\Boson\Window\NewWindowCreateInfo(
webview: new Serafim\Boson\WebView\HTMLWebViewCreateInfo(
html: '<button>Do Not Click Me!</button>',
),
),
);
$app->run();
$app = new Serafim\Boson\Application();
$app->webview->request('document.body.innerHTML')
->then(function(string $html){
var_dump($html);
});
$app->run();
$app = new Serafim\Boson\Application();
$app->webview->url = 'https://nesk.me';
$app->run();
$app = new Serafim\Boson\Application(
window: new Serafim\Boson\Window\NewWindowCreateInfo(
webview: new Serafim\Boson\WebView\URLWebViewCreateInfo(
url: 'https://nesk.me',
),
),
);
$app->run();
$app = new Serafim\Boson\Application();
$app->webview->styleBeforeLoad(<<<'CSS'
body {
background: #900;
}
CSS);
$app->run();
$app = new Serafim\Boson\Application(
window: new Serafim\Boson\Window\NewWindowCreateInfo(
webview: new Serafim\Boson\WebView\WebViewCreateInfo(
styles: [<<<'CSS'
body {
background: #900;
}
CSS],
),
),
);
$app->run();
$app = new Serafim\Boson\Application();
$app->webview->evalBeforeLoad(<<<'JS'
alert('hello');
JS);
$app->run();
$app = new Serafim\Boson\Application(
window: new Serafim\Boson\Window\NewWindowCreateInfo(
webview: new Serafim\Boson\WebView\WebViewCreateInfo(
scripts: [<<<'JS'
alert('hello');
JS],
),
),
);
$app->run();
$app = new Serafim\Boson\Application();
$app->webview->bind('foo', function(){
var_dump('Executed!');
});
$app->run();
$app = new Serafim\Boson\Application(
window: new Serafim\Boson\Window\NewWindowCreateInfo(
webview: new Serafim\Boson\WebView\WebViewCreateInfo(
functions: ['foo' => function(){
var_dump('Executed!');
}],
),
),
);
$app->run();
$app = new Serafim\Boson\Application();
$app->webview->eval('document.write("Hello World!")');
$app->run();
$app = new Serafim\Boson\Application();
$app->webview->request('document.location')
->then(function(array $data){
var_dump($data);
});
$app->run();