{"id":15722046,"url":"https://github.com/chopins/php-gtk","last_synced_at":"2025-05-13T02:49:51.386Z","repository":{"id":57071137,"uuid":"229110596","full_name":"chopins/php-gtk","owner":"chopins","description":"PHP bindings to the gtk+3 C library","archived":false,"fork":false,"pushed_at":"2020-10-02T08:04:05.000Z","size":701,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-01T06:02:45.575Z","etag":null,"topics":["ffi","gtk","gtk3","php"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chopins.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}},"created_at":"2019-12-19T17:56:52.000Z","updated_at":"2024-03-08T06:35:03.000Z","dependencies_parsed_at":"2022-08-24T14:54:25.815Z","dependency_job_id":null,"html_url":"https://github.com/chopins/php-gtk","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chopins%2Fphp-gtk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chopins%2Fphp-gtk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chopins%2Fphp-gtk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chopins%2Fphp-gtk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chopins","download_url":"https://codeload.github.com/chopins/php-gtk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253862737,"owners_count":21975583,"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":["ffi","gtk","gtk3","php"],"created_at":"2024-10-03T22:03:27.537Z","updated_at":"2025-05-13T02:49:51.347Z","avatar_url":"https://github.com/chopins.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"## php-gtk\nPHP bindings to the [gtk+3](https://www.gtk.org/) C library.\n\nThe project only expose GTK API by FFI\n\n**Requirements**\n* PHP \u003e= 7.4\n* PHP FFI extension available\n* toknot/ffi-extend \u003e=0.1\n\n**composer install** \n\n```\ncomposer require toknot/gtk\n\n```\n\n**Status**\n* support C function call of `GLib`, `GObject`, `Gio`, `Gtk`, `Atk`, `Gdk`, `Gdk-Pixbuf`, `Pango`\n* support C macro value and call of `GLib`,`GLib`, and a small part of `GTK`\n  \n**Defined Constants**\n\nDLL file name and header file name map list:\n\n```php\nclass PHPGtk {\n    public static $gtkDllMap  = [\n        self::GLIB_ID =\u003e ['name' =\u003e 'libglib', 'header' =\u003e ['glib'], 'require_version' =\u003e '2.56'],\n        self::GIO_ID =\u003e ['name' =\u003e 'libgio', 'header' =\u003e ['gio']],\n        self::GOBJECT_ID =\u003e ['name' =\u003e 'libgobject', 'header' =\u003e ['gtype', 'gobject']],\n        self::GTK_ID =\u003e ['name' =\u003e 'libgtk', 'header' =\u003e ['gtkfunc']],\n        self::GDK_ID =\u003e ['name' =\u003e 'libgdk', 'header' =\u003e ['gdk'], 'require_version' =\u003e '3.20'],\n        self::PIXBUF_ID =\u003e ['name' =\u003e 'libgdk_pixbuf', 'header' =\u003e ['pixbuf'], 'require_version' =\u003e '2.36'],\n        self::PANGO_ID =\u003e ['name' =\u003e 'libpango', 'header' =\u003e ['pango'], 'require_version' =\u003e '1.42'],\n        self::PANGO_CAIRO_ID =\u003e ['name' =\u003e 'libpangocairo', 'header' =\u003e ['pango_cairo']],\n        self::ATK_ID =\u003e ['name' =\u003e 'libatk', 'header' =\u003e ['atk'], 'require_version' =\u003e '2.28'],\n    ];\n......\n}\n```\n\n`Gtk\\PHPGtk::$gtkDllMap` determine load dynamic library name prefix and header file.\n\n**Load Dynamic Library**\n* In Linux, default find:\n  * when `PHP_INT_SIZE` equal 4, OS is 32bit, find `/usr/lib`\n  * when `PHP_INT_SIZE` equal 8, OS is 64bit, find `/usr/lib64`\n* specify lib path by self through `Gtk\\PHPGtk::gtk($libpath)`, \n  * if `$libpath` is string, value must be lib directory path\n  * will find match $libpath/$name-*.so, and load the first dll\n* specify lib name through set `name` value of specify lib row of `Gtk\\APP::$gtkDllMap`\n\n### Usage\n\n* basic example\n  \n    ```php\n    include dirname(__DIR__) . '/src/PHPGtk.php';\n    $gtk = \\GTK\\PHPGtk::gtk();\n    function activate()\n    {\n        global $gtk, $app;\n        try {\n        $window = $gtk-\u003egtk_application_window_new($app);\n        $gtk-\u003egtk_window_set_title($gtk-\u003eGTK_WINDOW($window), \"Window\");\n        $gtk-\u003egtk_window_set_default_size($gtk-\u003eGTK_WINDOW($window), 200, 200);\n        $gtk-\u003egtk_widget_show_all($window);\n        } catch(\\Error $e) {\n            echo $e;\n        }\n    }\n\n\n    function main($argc, $argv) : int\n    {\n        global $gtk, $app;\n\n        $app = $gtk-\u003egtk_application_new(\"org.gtk.example\", 0);\n\n        $gtk-\u003eg_signal_connect($app, \"activate\", 'activate');\n\n        $gapp = $gtk-\u003eG_APPLICATION($app);\n\n        $status = $gtk-\u003eg_application_run($gapp, $argc, $argv);\n\n        $gtk-\u003eg_object_unref($app);\n        return $status;\n    }\n    return main($argc, $argv);\n    ```\n* C Lib API call \n  * `PHPGtk` class can be call `Gtk`,`GLib`,`GObject`,`Gio`,`Gdk` function\n  * `PHPGtk::atk()` return `Gtk\\Atk`, can be call `GLib`,`GObject`,`ATK` function\n  * `PHPGtk::gdk()` return `Gtk\\Pixbuf`, can be call `GLib`, `GObject`, `GIO`, `GDK`,`gdk-pixbuf` function\n  * `PHPGtk::pango()` return `Gtk\\Pango`, can be call `GLib`,`GObject`,`Pango` function\n  * macro value get by same name constant of class\n  * macro function call by same name method of class\n  * lib version value defined by macro get by global same name  constant\n  * About gettext of `glib`:\n    * `Gtk\\Glib::$GETTEXT_PACKAGE`  name of `GETTEXT_PACKAGE` when compile `Glib`, default is null\n    * `Gtk\\Glib::$gettextDll`       path of gettext shared library, default is empty, if php eanble gettext, will use php gettext() function instead and the property invaild\n  * Gtk\\GtkWidget class provided simple OO method of call C function that related `GtkWidget`\n\n### Note:\n\n* Default, The number of callback function argument must less than 10, otherwise extra argument value always  `NULL`, only when `Gtk\\GtkAbstract::$gCallbackArgNum` be changed to other value\n* if C function for callback, use `GObject::G_CALLBACK($callable)` convert, the `$callable` is smailer `[$gtk, $c_func_name, true]`, it php callable array has 3 entries, 3rd is bool value\n* if new C variable be used occur segfault, try new unmanaged variable\n* most class is sub of `Gtk\\GtkAbstract`\n\n## For Windows\n1. get libgtk3 binary DLL file, see https://www.gtk.org/docs/installations/windows/\n2. copy libgtk3 all DLL file and dependency to your path, if use MSYS install, pass `YOUP_PATH/mingw32/bin` or `YOUP_PATH/mingw64/bin` to `PHPGtk::gtk($libpath)`, if not installed other package,In the path DLL file is libgtk dependency package\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchopins%2Fphp-gtk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchopins%2Fphp-gtk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchopins%2Fphp-gtk/lists"}