{"id":20398927,"url":"https://github.com/chopins/php-libui","last_synced_at":"2025-08-15T13:31:34.000Z","repository":{"id":50358523,"uuid":"208038479","full_name":"chopins/php-libui","owner":"chopins","description":"php bindings to the libui C library. ","archived":false,"fork":false,"pushed_at":"2024-06-11T01:22:49.000Z","size":582,"stargazers_count":71,"open_issues_count":0,"forks_count":8,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-07-28T10:04:07.358Z","etag":null,"topics":["ffi","gui","libui","php","ui"],"latest_commit_sha":null,"homepage":"","language":"PHP","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-12T11:46:40.000Z","updated_at":"2024-07-25T19:57:59.000Z","dependencies_parsed_at":"2024-06-10T08:38:17.142Z","dependency_job_id":"89705453-bad2-4ddb-9de5-06db7be9236b","html_url":"https://github.com/chopins/php-libui","commit_stats":{"total_commits":65,"total_committers":2,"mean_commits":32.5,"dds":0.01538461538461533,"last_synced_commit":"bb453ec9e9b46aa66af656ecfbf73c191cc5f9af"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chopins%2Fphp-libui","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chopins%2Fphp-libui/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chopins%2Fphp-libui/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chopins%2Fphp-libui/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chopins","download_url":"https://codeload.github.com/chopins/php-libui/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229915685,"owners_count":18144014,"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","gui","libui","php","ui"],"created_at":"2024-11-15T04:25:17.137Z","updated_at":"2024-12-16T06:04:35.019Z","avatar_url":"https://github.com/chopins.png","language":"PHP","readme":"# [中文说明](README_zh.md)\n# php-libui\nPHP bindings to the [libui](https://github.com/andlabs/libui) C library.\n\nlibui is a lightweight, portable GUI library that uses the native GUI technologies of each platform it supports.\n\n### Requirements\n* PHP \u003e= 8.1\n* PHP FFI extension available\n* libui latest version\n\n### A Simple Example\nsee https://github.com/chopins/http-request  \n\nfirst download libui dynamic library from https://github.com/andlabs/libui/releases or checkout source for self-build, then load in php code use following code\n```php\ninclude '/src/UI.php';\n$ui = new \\UI\\UI('/usr/lib64/libui.so'); //load libui dynamic library\n$ui-\u003einit();\n$mainwin = $ui-\u003enewWindow(\"libui Control Gallery\", 640, 480,1);\n$ui-\u003econtrolShow($mainwin);\n$ui-\u003emain();\n```\n\n## Note: When Call libui C function need remove `ui` prefix of name, then to lower case first char\n\n# Use UIBuild create UI\n\n##  Basic Usage:\n```php\ninclude '/src/UI.php';\n$ui = new \\UI\\UI('/usr/lib64/libui.so');\n$config = ['title' =\u003e 'test', 'width' =\u003e 600,'height' =\u003e 450];\n$build = $ui-\u003ebuild($config);\n$build-\u003eshow();\n```\n\n## build config structure\n* build config is xml file, see `tests/uibuild.xml`\n* **In xml file, all event attribute name must be prefix `on`**, `onclick`,`onchange`,`ondraw`, value is callable name, it is not Event instance, callable name support php variable and php callable:`$var`,`func_name`,`CLASS::method`, do not support array callable. variable is GLOBALS\n* attr value support GLOBALS variable and constant, prefix `$``@` as `$var` or `@CONST`\n* also build config support array, main key contain `body`,`menu` and *window attribute key*; in config array, element key is attr name, element value is attr value,similar the following:\n```php\n[\n    'title' =\u003e 'window title name',\n    'width' =\u003e 600,\n    'menu' =\u003e [],\n    'body'  =\u003e [\n        'name' =\u003e 'box'\n        'childs' =\u003e []\n    ]\n]\n```\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cwindow title=\"window title name\" width=\"600\" height=\"800\" fullscreen=\"0\" onclose=\"HTTP::quit\"\u003e\n\u003cmenu\u003e\n    \u003c/menu\u003e\n\u003cbody\u003e\n\u003c/body\u003e\n\u003c/window\u003e\n```\n\n## window attribute key list:\n| attr       | type      | Description     | Default Vlaue |\n| ---------- | --------- | --------------- | ------------- |\n| title      | string    | window title    | No Win Title  |\n| width      | int       | window width    | 800           |\n| height     | int       | window height   | 640           |\n| border     | int       | window border   | 0             |\n| margin     | int       | window margin   | 0             |\n| fullscreen | int       | window margin   | 0             |\n| quit       | \\UI\\Event | quit callback   | null          |\n| close      | \\UI\\Event | close callback  | null          |\n| resize     | \\UI\\Event | resize callback | null          |\n\n## menu array\nThe array level 1 of item element is one menu, similar:\n```php\n[\n    [\n        'title' =\u003e 'File',\n        'id'    =\u003e 'menu_id_1',\n        'childs' =\u003e [\n            ['title' =\u003e 'New File'],\n            ['title' =\u003e 'Open File'],\n        ]\n    ],\n    [\n        'title' =\u003e 'Edit',\n        'id'    =\u003e 'menu_id_1',\n        'childs' =\u003e [\n            ['title' =\u003e 'Undo'],\n            ['title' =\u003e 'Copy'],\n        ]\n    ],\n]\n```\nTop menu only contain `title`, `id`, `childs` , the `title` value will display in window, every element of `childs` array is submenu that display in drop-down menu. if element is string and equral `hr` will display a separator\n__current Build UI Config of submenu only contain the following attr:__\n\n| attr   | type      | Description                                                                              | require |\n| ------ | --------- | ---------------------------------------------------------------------------------------- | ------- |\n| title  | string    | menu title                                                                               | yes     |\n| type   | string    | menu type, value is `text`,`quit`,`about`,`preferences` or `checkbox`, default is `text` | no      |\n| click  | \\UI\\Event | click callback                                                                           | no      |\n| childs | array     | child menu list                                                                          | no      |\n\n## body array\nevery element key of `body` array is control config, `widget` element is control name and `attr` element is control attr. see `examples/table.php` __Build UI__ current only support the following control:\n\n1. `button`, Button control,contain the following attr:\n\n   | attr   | type      | Description                                                                                                                                                                                                                                                            | require |\n   | ------ | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |\n   | type   | string    | control type, smiliar HTML `\u003cbutton\u003e` tag of `type` attr, potential value is following:\u003cbr /\u003e  1. `file`, open file button\u003cbr /\u003e2. `save`, save file button\u003cbr /\u003e3. `font`, select font button\u003cbr /\u003e4. `color`, select color button\u003cbr /\u003e5. `button`, is default value | yes     |\n   | title  | string    | button label name                                                                                                                                                                                                                                                      | yes     |\n   | click  | \\UI\\Event | when click callback, when type `file` and `save` is after select file call                                                                                                                                                                                             | no      |\n   | change | \\UI\\Event | only when `color` and `font` available, select color or font be call                                                                                                                                                                                                   | no      |\n   | id     | string    |                                                                                                                                                                                                                                                                        | no      |\n\n2. `box` box layout,the following attr:\n\n   | attr      | type   | Description                                                                           | require |\n   | --------- | ------ | ------------------------------------------------------------------------------------- | ------- |\n   | dir       | string | layout direction, Specify one of `h` is horizontal and default value, `v` is vertical | yes     |\n   | padded    | int    | padding value,  default is `0`                                                        | no      |\n   | child_fit | int    | Whether to automatically adapt                                                        | no      |\n   | childs    | array  | sub control list                                                                      | no      |\n   | id        | string |                                                                                       | no      |\n\n3. `group` group layout, have `title` and `margin`, `child`,`id` attr\n4. `label`  text control, only has `title` and `id` attr\n5. `hr`   horizontal separator, no attr\n6. `vr`   vertical separator, no attr\n7. `input`  input control, the following attr:\n\n   | attr     | type      | Description                                                                                                                                                                                                                                                                                                                                                            | require |\n   | -------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |\n   | type     | string    | miliar HTML `\u003cinput\u003e` tag of `type` attr, specify one of the following value:\u003cbr /\u003e1. `password`  password entry control\u003cbr /\u003e2. `search`   search entry control\u003cbr /\u003e3. `textarea` multiline entry control\u003cbr /\u003e4. `radio`    radio\u003cbr /\u003e5. `select`   select\u003cbr /\u003e6. `checkbox` checkbox\u003cbr /\u003e7. `text`, is default value\u003cbr /\u003e8.`number` is Spinbox\u003cbr /\u003e9.`slider` | yes     |\n   | readonly | bool      | whether readonly                                                                                                                                                                                                                                                                                                                                                       | no      |\n   | wrap     | bool      | only `textarea` is available, `false` is non wrapping textarea                                                                                                                                                                                                                                                                                                         | no      |\n   | option   | array     | `radio` and `select` available, element value is option title, key is natural order number                                                                                                                                                                                                                                                                             | no      |\n   | change   | \\UI\\Event | exclude `checkbox` and `radio`                                                                                                                                                                                                                                                                                                                                         | no      |\n   | title    | string    | `checkbox` available                                                                                                                                                                                                                                                                                                                                                   | yes     |\n   | click    | \\UI\\Event | only `radio` and `checkbox` available                                                                                                                                                                                                                                                                                                                                  | no      |\n   | min      | int       | `number` and `slider` available                                                                                                                                                                                                                                                                                                                                        | yes     |\n   | max      | int       | `number` and `slider` available                                                                                                                                                                                                                                                                                                                                        | yes     |\n   | id       | string    |                                                                                                                                                                                                                                                                                                                                                                        | no      |\n   | editable | bool      | `select` available                                                                                                                                                                                                                                                                                                                                                     | no      |\n   \n8. `form`   form layout, has `padded`, `childs`,`id` attr, child widget has label attr\n9. `grid`   grid layout, the following attr:\n\n   | attr          | type   | Description | require |\n   | ------------- | ------ | ----------- | ------- |\n   | padded        | int    |             | no      |\n   | child_left    | int    |             | no      |\n   | child_top     | int    |             | no      |\n   | child_width   | int    |             | no      |\n   | child_height  | int    |             | no      |\n   | child_hexpand | int    |             | no      |\n   | child_halign  | int    |             | no      |\n   | child_vexpand | int    |             | no      |\n   | child_valign  | int    |             | no      |\n   | childs        | array  |             | no      |\n   | id            | string |             | no      |\n \n10. `table`  table control, table cell has change event, it is following sub key :\n\n    | attr  | type   | Description                                                                                                                                                                                                                                                                                                                                                      | require |\n    | ----- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |\n    | th    | array  | every element of value is array, key is id, has the following attr:\u003cbr /\u003e1. `editable`, `bool` type, the column is whether editable\u003cbr /\u003e2. `textColor`\u003cbr /\u003e3. `title`\u003cbr /\u003e4. `type`, specify value of `button`, `image`, `imgtext`, `progress`, `checkbox`, `checkboxtext`, `color`, `text` \u003cbr /\u003e5. widget has `change` attr, for row column change callback | yes     |\n    | tbody | array  | the table row value list, every element is one row value, when row of column is array has the following attr:\u003cbr /\u003e1. `image` type, has `src` `width` `height`\u003cbr /\u003e2. `color` type has `r`,`g`,`b`\u003cbr /\u003e3. `rowBgcolor`                                                                                                                                         | yes     |\n    | id    | string |                                                                                                                                                                                                                                                                                                                                                                  | no      |\n\n11. `tab`    tab control, has `page` sub array, `page` array every element value is page child control and key is page title\n12. `img`   image control, has flowing attr:\n\n    | attr   | type   | Description                                                                              | require |\n    | ------ | ------ | ---------------------------------------------------------------------------------------- | ------- |\n    | src    | array  | is image paths list, every element value is image file path, key is natural order number | yes     |\n    | width  | int    | the image control width, default is `src` first element image width                      | no      |\n    | height | int    | the image control heigth, default is `src` first element image width                     | no      |\n    | id     | string |                                                                                          | no      |\n\n13. `datetime` datetime control\n    \n    | attr   | type      | description                                   | require |\n    | ------ | --------- | --------------------------------------------- | ------- |\n    | type   | string    | specify one of value `time`,`date`,`datetime` | yes     |\n    | change | \\UI\\Event |                                               | no      |\n    | id     | string    |                                               | no      |\n\n14.  `progress`, has `id` attr\n15.  `area`,`canvas` create `Area`\n16.  `attribute` create `Attribute`\n17.  `drawtext` create `TextLayout`\n18.  `string` create a `AttributeString`\n19.  unsupport control must call libui C function by `UI\\UI`\n20.  `UI\\Event`, all event callback class, The signature of the callback is as follows:\n```php\n/**\n * @param UI\\Event $callable   The object instance of current event \n * \n * */\nfunction (UI\\Event $callable) {}\n```\n\n## Control common method:\n* show()\n* hide()\n* enable()\n* disable()\n* destroy()\n* parent()\n* setParent($parent)\n* isVisible()\n* isEnabled()\n\nspecify control see class statement in control directory\n\n## UI method\nsee `UI.php`\n\n## UIBuild method\nsee `UIBuild.php`\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchopins%2Fphp-libui","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchopins%2Fphp-libui","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchopins%2Fphp-libui/lists"}