简体   繁体   English

PHP:创建一个Mac可执行文件

[英]PHP: Create a Mac executable

I created a project years ago that allows a user to type in the IP address of a printer, select the printer model click submit and it would create a mac executable that would automatically install the print driver on the computer. 几年前,我创建了一个项目,该项目允许用户键入打印机的IP地址,选择打印机型号,然后单击提交,这将创建一个mac可执行文件,该文件将自动在计算机上安装打印驱动程序。

Unfortunately, I didn't back up the code and it's lost in the ether. 不幸的是,我没有备份代码,它已经丢失了。

I need to rebuild this project and the only part I'm stuck on is making the file an executable for Macs. 我需要重建该项目,而我唯一遇到的问题就是使该文件成为Mac的可执行文件。

On a mac, all I need to do is open up Terminal and type the following command to make it executable: 在Mac上,我需要做的就是打开Terminal,然后输入以下命令使其可执行:

 chmod +x filename

How do i do this in PHP? 如何在PHP中做到这一点?

Here's what i've attempted so far 到目前为止,这是我尝试过的

$file = fopen("installer", "w+") or die("file not open");

$kyocerascript = 'code for the script goes here';


fwrite($file,$kyocerascript) or die("Data not write");


fclose($file);
chmod("installer", "+x");

and i've tried 我已经尝试过

chmod($file, "+x");

My code creates the file without any issues but it's not an executable. 我的代码创建的文件没有任何问题,但它不是可执行文件。

I resolved this issue by zipping the file 我通过压缩文件解决了这个问题

To execute php at any type of machine you need to install php itself. 要在任何类型的机器上执行php,您都需要安装php本身。 You can install one of many "local servers" like: XAMPP, WAMP, etc. 您可以安装许多“本地服务器”之一,例如:XAMPP,WAMP等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM