“Hello world” in Phalanger PHP compiler

允我心安 提交于 2019-12-22 16:00:11

问题


I want my console program simply be run using Phalanger. I did not use IIS or .net in any way. Is it possible to use Phalanger in the same way that we use php.exe -f hello.php? How to compile and run following script using Phalanger.

<?php 
 echo "Hello World from Phalanger!";

回答1:


Phalanger works as a compiler and runtime for PHP.

The easiest way is to install Phalanger Tools for Visual Studio, which allows you to create, build and debug console application.

Anyway, without Visual Studio; first you have to compile the code

phpc  hello.php /out:hello.exe

Optionally, if you have more files in your project, you should list them all, and specify the entering script file

phpc.exe /target.exe /entrypoint:hello.php /root:. /recurse:true /out:hello.exe

Which compiles everything (*.php) in current directory and subdirectories, and specifies "hello.php" to be the entering script file.

This creates an executable file "hello.exe".

After you succeed with this basic example, you may be interested in using some PHP extensions (like GD2). This can be done by adding following parameter, "/r:PhpNetGd2, Version=3.0.0.0, Culture=neutral, PublicKeyToken=2771987119c16a03 which is the full name of the library containing GD2 functionality.



来源:https://stackoverflow.com/questions/18849763/hello-world-in-phalanger-php-compiler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!