{"id":13700127,"url":"https://github.com/siara-cc/php_webview","last_synced_at":"2025-06-15T21:36:29.859Z","repository":{"id":97919255,"uuid":"173480962","full_name":"siara-cc/php_webview","owner":"siara-cc","description":"Cross Platform WebView Interface for PHP-ians","archived":false,"fork":false,"pushed_at":"2019-03-06T09:50:44.000Z","size":69,"stargazers_count":25,"open_issues_count":2,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-30T17:44:34.141Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/siara-cc.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-03-02T17:58:50.000Z","updated_at":"2025-01-03T12:54:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"cd937fdf-efd3-4d1b-9a5e-502aa64e3017","html_url":"https://github.com/siara-cc/php_webview","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/siara-cc/php_webview","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siara-cc%2Fphp_webview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siara-cc%2Fphp_webview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siara-cc%2Fphp_webview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siara-cc%2Fphp_webview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/siara-cc","download_url":"https://codeload.github.com/siara-cc/php_webview/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siara-cc%2Fphp_webview/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260053694,"owners_count":22951944,"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":[],"created_at":"2024-08-02T20:00:48.863Z","updated_at":"2025-06-15T21:36:29.821Z","avatar_url":"https://github.com/siara-cc.png","language":"C","funding_links":[],"categories":["跨语言"],"sub_categories":[],"readme":"# Cross Platform WebView extension for PHP-ians\n\nThis WebView extension for PHP is built upon [WebView for C and Go](https://github.com/zserge/webview) written by Serge Zaitsev.\n\n# Why WebView for PHP\n\nPHP has always been a server side HTML preprocessor language.  Since it has a huge deployment base and developer base, it makes sense to make it available on the Front-end to build rich and responsive desktop applications.  This repository is first step towards this.\n\n# How it works\n\nThis repository makes WebView available as a PHP extension.  There are two functions provided by the extension: `webview()` and `webview_eval()`.\n\nGiving below is the PHP code of `main.php` which makes the API self-explanatory:\n\n```php\n\u003c?php\n\nfunction cb_from_webview($arg) {\n  webview_eval(\"document.write('\u003cdiv id=d1\u003eFirst script run from PHP\u003c/div\u003e')\");\n  echo \"In PHP:\", $arg, \"\\n\";\n  return \"document.body.innerHTML += 'Second script run from PHP';\";\n}\n\nwebview(\"file://\" . getcwd() . \"/index.html\", \"cb_from_webview\");\n\n?\u003e\n```\n\n`cb_from_webview()` is passed as second parameter to `webview()` function, which opens the URL specified in the first parameter. Whenever the script (JS) in the HTML page (index.html) calls `window.external.invoke(arg)`, the PHP callback function (`cb_from_webview()`) is invoked with the argument.\n\nThe callback function can choose to call `webview_eval()` as shown above.  Whatever string returned by this function is run as script.  If empty string is returned, it is not evaluated.\n\nThe callback function acts as a bridge between Javascript and PHP and may be called using JSON string as argument and may indicate the context of call (such as onload, onclick etc.) and corresponding data for the request or callback.\n\n# Usage\n\nThe procedure to build the extension differs from OS to OS.\n\n## Mac OS\n\nEnsure PHP 5.6+ or 7+ is installed. Clone this repository, make it current folder and run following commands:\n\n```sh\nphpize\n./configure CFLAGS=\"-DWEBVIEW_COCOA=1 -framework WebKit\"\nmake\n```\n\nOnce the `.so` file is successfully built, you can invoke the sample by using the following command:\n\n`php -dextension=modules/webview.so main.php`\n\n## Windows\n\nBuilding on Windows is a bit tricky. First download [PHP CLI](https://windows.php.net/downloads/releases/php-7.3.2-nts-Win32-VC15-x64.zip) corresponding to your system architecture (x86/x64) and Visual Studio version. Unzip to say `c:\\php7.3.2`, Open Visual Studio command prompt, change directory to this folder.  Clone this repository under ext folder.\n\nDownload [php-sdk](https://github.com/Microsoft/php-sdk-binary-tools) and unzip into different folder (say `c:\\php-sdk`).  On the command prompt, add path with `path=%path%;c:\\php-sdk\\bin;c:\\php-sdk\\msys2\\usr\\bin`.\n\nRun `buildconf.bat`, `configure --disable-all --enable-cli --enable-webview`.  Verify if configure will build `webview` as shared library.  Then run `nmake`.  This will build `php_webview.dll` into the corresponding folder such as `x64\\Release_TS`.\n\nTo run the example, cd to the folder such as `x64\\Release_TS`, run `php -dextension=php_webview.dll c:\\php7.3.2\\ext\\php_webview\\main.php`\n\n## Linux\n\nThe procedure to build on Linux is almost same as of MacOS except following commands (Tested with PHP 5.6 and 7.2 on Linux Mint 19).  Before running, ensure `pkg-config`, `gtk+-3.0` and `webkit2gtk-4.0` are installed using `apt`.\n\n```sh\nphpize\n./configure CFLAGS=\"-DWEBVIEW_GTK=1 `pkg-config --cflags --libs gtk+-3.0 webkit2gtk-4.0`\"\nmake\n```\n\nOnce the `.so` file is successfully built, you can invoke the sample by using the following command:\n\n`php -dextension=modules/webview.so -f main.php`\n\n# Screenshot\n\n![](ss_php_1.png?raw=true) ![](ss_php_2.png?raw=true)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiara-cc%2Fphp_webview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsiara-cc%2Fphp_webview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiara-cc%2Fphp_webview/lists"}