用于 Windows 的 PHP 编译器

2022-01-17 00:00:00 windows compiler-construction php

我有一个需要分发给客户端的命令行 php 应用程序.我只想给他们一个可执行文件,而不是安装 php 的说明;)

I have a command line php app that I need to distribute to a client. I just want to give them an executable, not instructions for installing php ;)

什么是好的 Windows php 编译器,包括对 php 5、curl、TLS 和我使用的一些其他库的支持?

What is a good php compiler for windows that includes support for php 5, curl, TLS, and a few other libs I use?

我需要控制内存和时间限制的使用,所以我必须能够使用自定义的 php.ini.(这也应该打包在exe中,而不是单独的文件)

I need to control memory and time limit usage, so I must be able to use a custom php.ini. (this should be packaged in the exe as well, not a separate file)

另外,我不希望代码被轻易提取.这不是一个很大的要求,但我宁愿不要在十六进制编辑器中查看源代码.

Additionally, I don't want the code to be easily extracted. This isn't a huge requirement, but I'd rather not have the source viewable in a hex editor.

我在 Google 上获得了一些点击,但如果有人实际使用过,您的反馈将非常宝贵.

I've got a few hits on Google, but if anyone has actually used one, your feedback would be invaluable.

编辑

如果我在开始的时候就知道要将它分发给客户端,我会使用 C#.但我没有.现在他们想买它.它必须非常简单.一个包含 php 解释器和我的脚本的可执行文件以及一个在运行 exe 时启动我的脚本的入口点.

If I knew I was going to distribute this to the client when i started, I'd have used C#. But I didn't. Now they want to buy it. It needs to be DEAD SIMPLE. one executable containing the php interpreter and my script plus an entry point to start my script when the exe is run.

如果我也不必重新分发 dll,那就太好了.

It would also be great if I didn't have to redistribute dll's either.

edit2

我正在寻找类似 phc 或 roadsend.phc不支持windows,roadsend不支持windows中的php5.

I am look for somthing along the lines of phc, or roadsend. phc doesn't support windows, and roadsend doesn't support php5 in windows.

推荐答案

好的,我想通了.有一个名为 phc-win 的开源程序.它支持 php 5.3.1,将脚本编译为字节码(混淆!),并且使用简单(甚至还有 gui).

Okay I figured it out. there is a open source program called phc-win. It supports php 5.3.1, compiles scripts to byte code (obfuscation!) and is simple to use (It even has a gui).

它需要一个 php-embed.ini 和您使用的任何 DLL,但它可以正常工作.

It needs a php-embed.ini and whatever DLL's you use, but it just works.

感谢大家的回答!

phc-win 0.3.1 (c) 2009 安德鲁菲茨杰拉德——联系人@swiftlytilting.com PHP版本:5.3.1

phc-win 0.3.1 (c) 2009 Andrew Fitzgerald - contact@swiftlytilting.com PHP Version: 5.3.1

  • 编译单个文件:

  • To compile a single file:

  • 从文件"菜单中选择编译单个文件".
  • 然后选择要编译的文件.

构建一个包含目录中所有文件和所有子文件的EXE目录:

To build an EXE containing all files in a directory and all sub directories:

  • 从文件"菜单中选择编译目录".
  • 选择项目文件夹.
  • 选择主程序文件.
  • phc-win 随后将递归扫描指定目录.
  • 所有扩展名中带有'php'的文件都将被编译成.phb 文件.
  • 这些 .phb 文件以及目录树中的所有文件都将添加到项目 EXE 中.

  • Choose 'Compile directory' from the File menu.
  • Select the project folder.
  • Select the main program file.
  • phc-win will then recursively scan the specificed directory.
  • All files with 'php' anywhere in the extension will be compiled into .phb files.
  • These .phb files, along with all files in the directory tree will be added to the project EXE.

创建 EXE 后,系统会询问您有关 EXE 类型的信息:

Once the EXE has been created, you will be asked about the EXE type:

  • CONSOLE(显示 DOS 框)
  • WINDOWS(无 DOS 框).

将 EXE 与所需的 DLL 文件放在同一目录中,然后php-embed.ini 文件(如果需要).

Place the EXE in the same directory with the required DLL file(s) and php-embed.ini file if needed.

相关文章