A robust cross-platform GUI toolkit for PHP that leverages Tcl/Tk via PHP's FFI extension. This library offers a professional API for building graphical interfaces in PHP, seamlessly abstracting Tcl/Tk complexities behind intuitive widget classes.
demo-video.mp4
Install dependencies:
composer require developersharif/php-gui
- src/: Core PHP source code
- Widget/: Contains widget classes (Window, Button, Label, etc.).
- ProcessTCL.php: Wraps the Tcl interpreter via FFI.
- Application.php: Manages the event loop and application lifecycle.
- Linux: ☑️
- Windows: ☑️
- macOS: Coming soon.
For detailed documentation on each widget and component, please refer to the documentation files in the docs folder:
Below is a sample usage example to get you started:
<?php
require_once __DIR__ . '/vendor/autoload.php';
use PhpGui\Application;
use PhpGui\Widget\Window;
use PhpGui\Widget\Label;
use PhpGui\Widget\Button;
use PhpGui\Widget\Input;
$app = new Application();
$window = new Window(['title' => 'Example', 'width' => 500, 'height' => 300]);
$label = new Label($window->getId(), ['text' => 'Hello, PHP GUI!']);
$label->pack(['pady' => 20]);
$button = new Button($window->getId(), [
'text' => 'Click Me',
'command' => function() use ($label) {
$label->setText('Button clicked!');
}
]);
$button->pack(['pady' => 10]);
$input = new Input($window->getId(), ['text' => 'Type here...']);
$input->pack(['pady' => 10]);
$app->run();
This project is licensed under the MIT License.