PHPackages                             php-io-extensions/gtk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. php-io-extensions/gtk

ActivePhp-ext

php-io-extensions/gtk
=====================

PHP-Controllable GTK4 Toolkit Extension

0.7.0(today)00MITPHP &gt;=8.2

Since Aug 14Pushed todayCompare

[ Source](https://github.com/php-io-extensions/gtk)[ Packagist](https://packagist.org/packages/php-io-extensions/gtk)[ RSS](/packages/php-io-extensions-gtk/feed)WikiDiscussions 0.7.x Synced today

READMEChangelogDependenciesVersions (3)Used By (0)

php-gtk (php-io-extensions)
===========================

[](#php-gtk-php-io-extensions)

[![PHP](https://camo.githubusercontent.com/c43902a50e55ff766fc179e27d9b9a292ef8fcadbdd4d855bb077a334e2f9b46/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d254532253839254135253230382e322d3737376262343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://www.php.net)[![GTK](https://camo.githubusercontent.com/f0b06066f4de54706714dbef805cda9fd5041d0c0949470d147d8bae92bfc2d6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f47544b2d254532253839254135253230342e31302d343738343866)](https://www.gtk.org/)[![Built with Zephir](https://camo.githubusercontent.com/8e72a9e9874ec036e66f84af12bd028857d1f200674b7acaa9eb97271a123f7c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6275696c74253230776974682d5a65706869722d666636613030)](https://zephir-lang.com/)[![Platform](https://camo.githubusercontent.com/ec3ffbe89f8d1f152dec06cd451833acef4ded894b500c724cb70033418ec0be/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d6c696e75782d6c6967687467726579)](#requirements)[![License: MIT](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](#license)

> PHP extension for **GTK4** — built with [Zephir](https://zephir-lang.com/). This is **not** the legacy PECL `php-gtk` (PHP 5).

`gtk` exposes GTK4 C APIs to PHP 8.2+ as static methods under `Gtk\GTK\…`. It **binds the library**. It does not orchestrate applications, scenes, or tubes. Downstream PHP (a future `microscrap/gtk`) owns ergonomics and enums.

Linux only (Debian / Ubuntu). Darwin toolkit host is `php-io-extensions/metal`. Windows is excluded.

---

Requirements
------------

[](#requirements)

ComponentMinimumNotesPHP8.2ZTS and NTSGTK44.10.0`pkg-config gtk4` — Debian/Ubuntu package `libgtk-4-dev`OSLinuxDebian and Ubuntu share the same apt namesCompilerC11`gcc` on the Linux boxZephir0.19.xOnly required to regenerate `ext/` (`scripts/prepare-ext.sh`)This repository does **not** compile on macOS. Use `build-linux.sh` on Debian or Ubuntu.

---

Installation (Linux)
--------------------

[](#installation-linux)

Debian and Ubuntu use the same packages, so there is one script:

```
bash build-linux.sh
```

That script:

1. Installs `libgtk-4-dev` + PHP headers if needed
2. Runs `scripts/prepare-ext.sh` if `ext/` has not been generated (needs Zephir)
3. `phpize` → `./configure --enable-gtk` → `make` → install `.so` + `30-gtk.ini`

PIE (after `ext/` is committed):

```
pie install php-io-extensions/gtk
```

---

What this extension is
----------------------

[](#what-this-extension-is)

Opaque `int` handles are GObject pointers. `0` is NULL / failure. PHP GC does **not** free natives — pair create with `gObjectUnref` / `gtkWindowDestroy`.

No PHP class constants. Flag ints live in the app or a future microscrap enum (FULLY UPPERCASE backed cases).

ClassC library`Gtk\GTK\Gtk``gtk_init_check`, version getters`Gtk\GTK\GtkError`last bind-layer failure string`Gtk\GTK\Application\GtkApplication``gtk_application_new`, `g_application_run`, `g_application_quit``Gtk\GTK\Window\GtkWindow`window / application-window, title, size, child, present, close`Gtk\GTK\Widget\GtkWidget`visible, expand, size request, queue draw`Gtk\GTK\Button\GtkButton`button + label`Gtk\GTK\Label\GtkLabel`label + text`Gtk\GTK\Image\GtkImage`image from file / icon`Gtk\GTK\Picture\GtkPicture`picture from filename`Gtk\GTK\Spinner\GtkSpinner`spinner start/stop`Gtk\GTK\ProgressBar\GtkProgressBar`fraction / text / pulse`Gtk\GTK\Separator\GtkSeparator`separator`Gtk\GTK\Entry\GtkEntry`entry + text / placeholder / visibility`Gtk\GTK\PasswordEntry\GtkPasswordEntry`password + peek`Gtk\GTK\TextView\GtkTextView`multiline text`Gtk\GTK\CheckButton\GtkCheckButton`check button + label + active`Gtk\GTK\ToggleButton\GtkToggleButton`toggle + label + active`Gtk\GTK\GtkSwitch\GtkSwitch`switch + active (`Switch` is a reserved PHP word)`Gtk\GTK\SpinButton\GtkSpinButton`numeric spin`Gtk\GTK\Scale\GtkScale`slider`Gtk\GTK\DropDown\GtkDropDown`string drop-down`Gtk\GTK\SearchEntry\GtkSearchEntry`search field`Gtk\GTK\HeaderBar\GtkHeaderBar`header bar (use `gtkWindowSetTitlebar`)`Gtk\GTK\MenuButton\GtkMenuButton`menu button + popover`Gtk\GTK\Popover\GtkPopover`popover + child`Gtk\GTK\ScrolledWindow\GtkScrolledWindow`scroll child`Gtk\GTK\Notebook\GtkNotebook`tabs`Gtk\GTK\Stack\GtkStack`named pages`Gtk\GTK\Paned\GtkPaned`split pane`Gtk\GTK\Grid\GtkGrid`grid attach`Gtk\GTK\CenterBox\GtkCenterBox`start / center / end`Gtk\GTK\Overlay\GtkOverlay`overlay children`Gtk\GTK\ListBox\GtkListBox`list rows`Gtk\GTK\ListView\GtkListView`list view + StringList / SingleSelection / ListItem`Gtk\GTK\AlertDialog\GtkAlertDialog`alert show / choose`Gtk\GTK\FileDialog\GtkFileDialog`open / save / folder`Gtk\GTK\ColorDialog\GtkColorDialog`color choose`Gtk\GTK\FontDialog\GtkFontDialog`font choose`Gtk\GTK\Box\GtkBox`box + append/remove`Gtk\GTK\GLArea\GtkGLArea`GPU view widget (does not create a window)`Gtk\GTK\GtkGLib``g_object_ref` / `unref`, `g_signal_connect``g_application_run` **blocks** the PHP thread. That is the GTK Application run loop.

---

Examples
--------

[](#examples)

Headless (no display):

```
php examples/proof_of_work.php
```

One window + button (needs `WAYLAND_DISPLAY` or `DISPLAY`):

```
php examples/proof_window.php
```

Orientation ints for `gtkBoxNew` (define in the app, not in this extension):

```
const GTK_ORIENTATION_HORIZONTAL = 0;
const GTK_ORIENTATION_VERTICAL = 1;
```

---

Regenerating `ext/`
-------------------

[](#regenerating-ext)

On Linux, after changing `.zep` files:

```
bash scripts/prepare-ext.sh
```

Then commit the generated `ext/` C (phpize junk is gitignored). Do not run `make` on macOS.

---

License
-------

[](#license)

MIT. See [LICENSE](LICENSE).

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10563160?v=4)[Angel Gonzalez](/maintainers/projectsaturnstudios)[@projectsaturnstudios](https://github.com/projectsaturnstudios)

---

Top Contributors

[![projectsaturnstudios](https://avatars.githubusercontent.com/u/10563160?v=4)](https://github.com/projectsaturnstudios "projectsaturnstudios (2 commits)")

### Embed Badge

![Health badge](/badges/php-io-extensions-gtk/health.svg)

```
[![Health](https://phpackages.com/badges/php-io-extensions-gtk/health.svg)](https://phpackages.com/packages/php-io-extensions-gtk)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
