1. Go to this page and download the library: Download developersharif/php-gui library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
developersharif / php-gui example snippets
PhpGui\Application;
use PhpGui\Widget\Window;
use PhpGui\Widget\Label;
use PhpGui\Widget\Button;
$app = new Application();
$window = new Window(['title' => 'Hello PHP GUI', 'width' => 400, 'height' => 250]);
$label = new Label($window->getId(), ['text' => 'Hello, World!']);
$label->pack(['pady' => 20]);
$button = new Button($window->getId(), [
'text' => 'Click Me',
'command' => fn() => $label->setText('You clicked it!'),
]);
$button->pack();
$app->run();
// In dev: hot-reloads via the Vite dev server (HMR works)
// In prod: loads dist/ from disk — no server needed
$wv->serveVite(__DIR__ . '/frontend/dist');
$wv->enableFetchProxy(); // add this before serveFromDisk() / serveVite()
PhpGui\Application;
use PhpGui\Widget\WebView;
$app = new Application();
$wv = new WebView(['title' => 'My Vite App', 'width' => 1024, 'height' => 768]);
$wv->enableFetchProxy();
$wv->serveVite(__DIR__ . '/frontend/dist');
// Expose a PHP function to JavaScript
$wv->bind('readFile', function (string $reqId, string $args) use ($wv): void {
$path = json_decode($args, true)[0];
$content = is_file($path) ? file_get_contents($path) : null;
$wv->returnValue($reqId, 0, json_encode($content));
});
$wv->onClose(fn() => $app->quit());
$app->addWebView($wv);
$app->run();
ini
> ; php.ini
> extension=ffi
> ffi.enable=true
>
bash
composer
bash
php app.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.