What is WinBinder?WinBinder is a new development platform that uses PHP to build Windows programs in a straightforward and simple way. Even short scripts with a few dozen lines can build a useful program, thanks to the power and flexibility of PHP. WinBinder is easy to use and produces very fast and rewarding results with minimum effort.How does it work?The WinBinder technology benefits from the new CLI SAPI (Command Line Interface / Server Application Programming Interface) that was officially introduced in PHP 4.3.0 plus a custom DLL (a Windows library) as the key elements to build a flexible and powerful Windows development platform. A callback mechanism is created so the application script can easily process the events generated by the Windows controls. A simple RC parser allows Windows resource files to be used directly and avoids the need for a separate compilation step. It is also easy to include any existing PHP code library and even use preexistent template-based PHP code to create Windows applications that behave as their web counterparts. This arrangement is compliant to the PHP guidelines.
--------------------------------------------------------------------------------If you are installing WinBinder from an installer (winbinder_setup.exe), just
follow the instructions on the setup wizard and ignore the two following steps.MANUAL INSTALLATION
--------------------------------------------------------------------------------1) Create a new folder in your hard disk to hold the files, like C:\WinBinder.2) Unzip all files from the WinBinder archive to the new folder, maintaining the
original folder structure.3) If this is an upgrade or if this package already contains the PHP binaries,
you are done. If this the first time you are installing WinBinder, proceed to
PHP installation below.MANUAL PHP INSTALLATION
------------------------------------------------------------------------------To run WinBinder you must install a copy of PHP version 4.3 or 5 in the
WinBinder directory.The advantage of PHP 4.3 over PHP 5 is a smaller footprint. PHP 5 has about
3.5 MB (1.8 MB zipped) while PHP 4.3 has about 1.4 MB (630 kB zipped). The
advantage of PHP 5 is that it has much better OO support and new functions.1) If you just want to run WinBinder and do not need PHP for anything else,
you may download a minimal PHP installation for WinBinder from the page
http://winbinder.sourceforge.net/download.php. If you prefer the full version
of PHP, go to http://www.php.net/downloads.php, find the caption "Windows
Binaries" and download the latest stable version of PHP 4 or 5 as a zip
package (not an installer).2) Locate the files you will need. For PHP 4, the files are: php.exe
php4ts.dllFor PHP 5 you will need: php.exe
php-win.exe
php5ts.dll3) Copy the files to the PHP folder (in the example, C:\WinBinder\PHP\PHP4
or C:\WinBinder\PHP\PHP5) to complete the installation. Keep in mind that
it does no harm to have more than one copy of PHP in the same computer, even
if versions are different.4) If you are running Windows 98 or Me and keep getting "Unable to load dynamic
library" errors, try using a fully qualified path name for the WiBinder
extension. To do that, first locate the file php.ini. This file is located in
the \PHP\PHP4 or PHP\PHP5 folder. Look for the "extension_dir" entry in the
INI file and change it to show the complete path to your extension folder. In
the example above, you would change it from "ext/" to
"c:/winbinder/php/php4/ext/" or "c:/winbinder/php/php5/ext/".
--------------------------------------------------------------------------------Once WinBinder and PHP are installed, perform the following steps:1) In Windows Explorer, associate the .PHPW extension ('W' stands for Windows)
with php-win.exe. This version of PHP has the advantage of not opening a console
window.2) There are some code examples in the CODE folder. To see WinBinder in action,
go to the CODE\HELLO folder and double-click hello.phpw to run it. You may then
take a look at the other scripts available in the other folders.3) You can also create a tool in your favorite PHP code editor to edit and run
scripts. For PHP code development, it is best to run the console version of PHP
(php.exe) instead of php-win.exe. This way you will be able to see the console
output. Follow the instructions from the text editor, then associate a keyboard
shortcut, e.g. F5, to the new tool. Thus you may open a .phpw file and run it
simply by pressing F5. Look in the TOOLS folder for specific code editor
information.
安装比较简单了
下载winbinder包,下载php4.3.XX,
将php4.3.xx下的php4ts.dll和php.exe(或者php-win.exe)复制到
winbinder包下php/php4/下
然后将code/sample目录下的phpw扩展名的文件与刚才复制过去的php.exe进行文件关联
即右键选择打开方式,然后将程序定位到winbinder/php/php4/php.exe
或winbinder/php/php4/php-win.exe
然后双击phpw文件就能看到结果了
php.exe与php-win.exe的不同之处在于php.exe会多一个DOS窗口,
如果想调试,还是用php.exe吧,能在dos窗口看到程序的输出信息
用他开发点桌面应用还是很不错的。
还有是界面可以用WINSAM设计,呵呵,满方便的。
另外可以用PECL里的一个工具把一些简单的应用打包成EXE文件,直接运行。但是复杂的就打包不起来了。当然我用的是几个月以前的工具包了,新的或许可以了,呵呵~~
http://phpexpert.51.net/doc/winbinder/
由于这个文档没有CVS,也不是用DOCBOOK之类的写的,维护起来也很不方便.
直接翻译 html 文件简直是一种折磨.安装
--
下载winbinder
把 php_winbinder.dll 的相应版本(PHP5/PHP4)复制到php 的 extensions 的扩展模块目录下.
在php.ini中加入
extension=php_winbinder.dll
把 下载包中的 code/inc 下的.php程序放到 php.ini 指定的 include 目录下
或干脆和开发的程序放在一起.--
配置
--
暂时没有发现要配置的项.
--
小例子(一个什么也不能做只有界面的程序,资源文件就不帖了)
--
<?php$basedir = dirname(__FILE__)."/";
include $basedir . "inc/winbinder.php"; // 引入 WinBinder 库//程序参数define("APPNAME", "唯她 PHP 工具箱"); // 应用程序名
define("PATH_RES", $basedir . "res/"); // 资源路径//-------------------------------------------------------------------- CONSTANTS// 控件ID (有点VC++的味道)define("ID_INSTALL_APACHE", 102);
define("ID_INSTALL_PHP", 103);
define("ID_INSTALL_MYSQL", 104);
define("ID_INSTALL_ALL", 105);define("ID_CONFIG_APACHE", 201);
define("ID_CONFIG_PHP", 202);
define("ID_CONFIG_MYSQL", 203);define("ID_TOOLS_SETUP", 301);
define("ID_TOOLS_RESTART_APACHE", 302);
define("ID_TOOLS_RESTART_MYSQL", 303);
define("ID_TOOLS_STOP_APACHE", 304);
define("ID_TOOLS_STOP_MYSQL", 305);define("ID_HELP_UPGRADE", 401);
define("ID_HELP_WEBSITE", 401);
define("ID_HELP_ABOUT", 402);// EXE file structures
define("WINHEADER_SIZE", 93);// 定义常量define("ABOUT",
APPNAME . "\n\n" .
"唯她PHP工具箱是使用 PHP+WinBinder 制作的一款用于在 Windows 系统下的 PHP 及相关软件的配置管理工具.\n\n" .
"本程序运行于 PHP 4.3 或 PHP 5 之上.\n\n" .
"作 者:Vital(唯她) [email protected]\n".
"主 页:http://www.m121m.net\n" .
"软件主页:http://www.m121m.net/products/VitalPhpTools\n");// 创建主窗口$mainwin = wb_create_window(NULL, PopupWindow, APPNAME, 640, 480);
wb_set_handler($mainwin, "process_main");// 创建菜单, 工具栏wb_create_control($mainwin, Menu, array(
"安装与更新(&I)",
array(ID_INSTALL_APACHE, "安装 &Apache", NULL, PATH_RES ."apache.bmp"),
array(ID_INSTALL_PHP, "安装 &PHP", NULL, PATH_RES ."php.bmp"),
array(ID_INSTALL_MYSQL, "安装 &MySQL", NULL, PATH_RES ."mysql.bmp"),
array(ID_INSTALL_ALL, "安装 Apache+PHP+MySQL", NULL, NULL),
null,
array(IDCLOSE, "退出 (&X)\tAlt+F4", NULL, PATH_RES ."menu_exit.bmp"),
"配置管理(&C)",
array(ID_CONFIG_APACHE, "&Apache 配置", NULL,PATH_RES ."apache.bmp"),
array(ID_CONFIG_PHP, "&PHP 配置", NULL,PATH_RES ."php.bmp"),
array(ID_CONFIG_MYSQL, "&MySQL 配置", NULL,PATH_RES ."mysql.bmp"),
"日志(&L)",
array(ID_LOG_APACHE, "查看 &Apache 日志", NULL,PATH_RES ."apache.bmp"),
array(ID_LOG_PHP, "查看 &PHP 日志", NULL,PATH_RES ."php.bmp"),
array(ID_LOG_MYSQL, "查看 &MySQL 日志", NULL,PATH_RES ."mysql.bmp"),
"工具(&T)",
array(ID_TOOLS_SETUP, "设置(&C)", NULL,PATH_RES."config.bmp","Ctrl+P"),
array(ID_TOOLS_STOP_APACHE, "停止 Apache 服务(&S)", NULL,PATH_RES."stop_apache.bmp"),
array(ID_TOOLS_RESTART_APACHE, "重起 Apache 服务(&R)", NULL,PATH_RES."restart_apache.bmp"),
array(ID_TOOLS_STOP_MYSQL, "停止 MySQL 服务(&D)", NULL,PATH_RES."stop_mysql.bmp"),
array(ID_TOOLS_RESTART_MYSQL, "重起 MySQL 服务(&M)", NULL,PATH_RES."restart_mysql.bmp"),
"帮助(&H)",
array(ID_HELP_UPGRADE, "检查与更新(&U)...", NULL, PATH_RES . "upgrade.bmp"),
array(ID_HELP_WEBSITE, "软件主页(&W)...", NULL, PATH_RES . "upgrade.bmp"),
array(ID_HELP_ABOUT, "关于(&A)...\tF1", NULL, PATH_RES . "menu_help.bmp", "F1"),
));//工具条(图标在资源文件下)
$toolbar = wb_create_control($mainwin, ToolBar, array(
null,
array(ID_CONFIG_APACHE, NULL, "安装 Apache", 1),
array(ID_CONFIG_PHP, NULL, "安装 PHP", 22),
array(ID_CONFIG_MYSQL, NULL, "安装 MySQL", 12),
null,
array(ID_HELP_ABOUT, NULL, "帮助", 13),
), 0, 0, 16, 15, 0, 0, PATH_RES . "toolbar.bmp");$mainFrame = wb_create_control($mainwin, Frame, "", 0, 18, 634, 400);$maintab = wb_create_control($mainFrame, TabControl,
"Tab1\nTab2\nTab3\nTab4\nTab5", 4, 4, 305, 185, 101, WBC_VISIBLE);// Create child controlswb_create_control($maintab, Slider, "", 110, 30,140, 25, 102, 0, 0);
wb_create_control($maintab, ScrollBar, "", 20, 30, 16,120, 103, 0, 0);
wb_create_control($maintab, ScrollBar, "", 115, 90,140, 16, 104, 0, 0);wb_create_control($maintab, Label, "Hi", 40, 40, 70, 20, 201, 0, 1);
wb_create_control($maintab, CheckBox, "Op1", 40, 60, 70, 20, 202, 0, 1);
wb_create_control($maintab, CheckBox, "Op2", 40, 80, 70, 20, 203, 0, 1);wb_create_control($maintab, RadioButton,"Op1", 40, 40, 60, 20, 301, 0, 2);
wb_create_control($maintab, RadioButton,"Op2", 40, 60, 60, 20, 302, 0, 2);
wb_create_control($maintab, RadioButton,"Op3", 40, 80, 60, 20, 303, 0, 2);wb_create_control($maintab, Label, "Hey", 40, 40, 70, 20, 401, 0, 3);
wb_create_control($maintab, CheckBox, "Op1", 40, 60, 70, 20, 402, 0, 3);
wb_create_control($maintab, CheckBox, "Op2", 40, 80, 70, 20, 403, 0, 3);wb_create_control($maintab, Slider, "", 110, 30,140, 25, 501, 0, 0);
wb_create_control($maintab, ScrollBar, "", 20, 30, 16,120, 502, 0, 0);
wb_create_control($maintab, ScrollBar, "", 115, 90,140, 16, 503, 0, 0);
//状态栏
$statusbar = wb_create_control($mainwin, StatusBar, "欢迎使用唯她 PHP 工具箱!");
wb_set_image($mainwin, PATH_RES . 'hyper.ico');wb_set_handler($mainwin, "process_main"); //设置主处理函数.//主循环
wb_main_loop();
/* 主处理函数 */function process_main($window, $id)
{
global $toolbar,$maintab; switch($id) { case ID_HELP_WEBSITE:
if(!wb_exec("http://expert.51.net/"))
wb_message_box($window, "无法打开软件主页.");
break;
case ID_HELP_ABOUT:
$about = wb_create_window(NULL, ModalDialog, " 关于".APPNAME."...", 480, 330);
$list = wb_create_control($about, EditBox, ABOUT, 0, 0, 475, 250, 101, WBC_MULTILINE | WBC_READONLY);
wb_create_control($about, PushButton, "Close", 80, 260, 80, 22, IDCANCEL); wb_set_handler($about, "process_dlg");
break;
case $maintab:
$val = wb_get_value($ctrl);
wb_set_value(wb_get_control($window, 103), $val);
wb_set_value(wb_get_control($window, 104), $val);
break; case IDCLOSE:
wb_destroy_window($window);
break;
}
}function process_dlg($window, $id)
{
switch($id) {
case IDCLOSE:
case IDCANCEL:
wb_destroy_window($window);
break;
}
}
?>
-----
遇到的问题
稳定性(可能是正处于测试阶段,反正...)====
发布的程序也很小.(把没有使用的 php 扩展模块删减后,php本身并不大)
加上开发的程序也不大,而且可以打包成一个可执行文件.(写大型软件自然是不适合的)
那个winbinder目录下面已经有了php.exe了。
就是双击phpw文件打开方式。选择winbinder下面的php.exe可以了
那有1个winbinder版,但只有几帖
转个安装帖:
WinBinder 安装方法
下载套件
先到 http://www.hypervisual.com/winbinder/download.php 下载以下档案:
- WinBinder Libraries : winbinder_0.3x.xxx.zip (下载 ZIP 档即可)
- Minimal PHP : php5_minimal.zip & php5_libs.zip
- WinBinder OOi : wb_ooi_0.3.zip安装
1. 将 winbinder_0.3x.xxx.zip 解压缩至 C:\WinBinder 下。应该会有以下文件夹:
- Code
- PHP
- Source
- Tools2. 解压缩 wb_ooi_0.3.zip 至 C:\WinBinder 下,将其中的 Code 及 Tools 文件夹复盖掉上面的文件夹。 (其实是新增一些档案)3. 为了不和已安装的 PHP 起冲突,建议安装 PHP 最小化版本。将上面的 php5_minimal.zip 及 php5_libs.zip 内的档案,解压缩至 C:\WinBinder\PHP\PHP5 下。4. 打开档案总管,选择「工具 / 文件夹选项 / 档案类型」。新增一个扩展名「PHPW」,然后将打开档案的程序选择为「C:\WinBinder\PHP\PHP5\php-win.exe」。运行 Script
到 C:\WinBinder\Code\Sample 下,就可以看到很多 .phpw 档。随便找一个点击两下,试试看能不能正常运行。注意事项
1. 这里所用的 PHP 最小化版本,其设置档为 C:\WinBinder\PHP\PHP5\php.ini 。所以不会和站点用的 PHP 打架。2. 用 php.exe 也可以运行,不过会看到一个很丑的 Console 窗口大剌剌地跟在运行接口的后头,而且还会显示一堆原始码。 (注:这样的方式能够知道程序错在哪。)3. 如果要把程序码搬到其他地方运行的话,要注意路径的问题。4. 其他请有经验的先进们补充罗。5. 如果在 PHP.INI 中,将短标签关掉,会造成部份 PHPW 程序无法运行。如果决定要关闭短标签,则需要把 C:\WinBinder\Code\* 中的 PHP 档案内之 <? 改为 <?php 。贫身亦飘然 (jaceju) 修改于 西元 2005 年 05 月 30 日 09:07 AM