Page 1 of 1

phpc compiling generates invalid namespaces

PostPosted: September 8th, 2015, 11:34 am
by Neokil
Hello,

I am currently trying to integrate a PHP-Libary into my C#-MVC-Application.
When I saw that there is a php-Compiler I tried to use it doing the following command:
phpc /target:dll /out:Teamspeak3.dll /recurse:TeamSpeak3 /root:.

The Compiler is giving me some warings about unknown functions, but it succeds. The Problem is, I cannot use the DLL created since the all the Namespaces are in angle-brackets which is invalid.

Any advice what I could try?


Greetings
Neokil

Re: phpc compiling generates invalid namespaces

PostPosted: September 8th, 2015, 12:49 pm
by Jakub Misek
hi,

Phalanger compiler works in two modes:
- standard: PHP files are compiled as a class within 'weird' namespace. (http://wiki.php-compiler.net/Multi_Script_Assembly)
- pure: compilation similar to C# compiler - all files are compiled all together, and resulting DLL contains nice classes within their namespace. (http://wiki.php-compiler.net/Pure_mode)

Add following to your command line (or use Phalanger Tools for Visual Studio, and set compilation mode: pure in project properties):
Code: Select all
/pure+


note: wiki is slightly old, will be updated

Re: phpc compiling generates invalid namespaces

PostPosted: September 8th, 2015, 1:08 pm
by Neokil
ok, I tried that it seems "include"-Keyword is not supported.
Since I dont want to rewrite the whole library so it will not use include, I am not sure how to go from here.
Might it be better to use the ScriptingContext than trying to convert the Library into .NET?

Re: phpc compiling generates invalid namespaces

PostPosted: September 8th, 2015, 1:35 pm
by Jakub Misek
right, include cant be used in 'pure' mode, since it is not needed - all the files are included by default already.

When using standard mode, Phalanger has to deal with all the php files separately, that's why it is in separate namespaces. In this way, you have to use it as shown at http://wiki.php-compiler.net/Multi_Scri ... T_language)_project
Note standard mode may have slower startup performance, since many classes have to be compiled at runtime yet

Re: phpc compiling generates invalid namespaces

PostPosted: September 10th, 2015, 12:08 pm
by Neokil
hmm... ok I commented out all includes and tried to recompile it.
It worked but at runtime it threw me an error that some function is missing, so I looked into the log-files a little bit closer and found the list of unknown functions which had about 250 entrys.
And when I sat down to replace all the unknown functions after about an hour I decided it would be easier to create a new framework than replacing all the unknown commands in this one.
I am not sure what scripts phalanger can compile for when I look in the list of unknown functions there are things like "strlen" and "substr" as well as "preg_match" which seem to me like some of the functions that are used quite often.

Re: phpc compiling generates invalid namespaces

PostPosted: September 19th, 2015, 11:04 pm
by Jakub Misek
all the functions you named are defined in PhpNetClasslibrary.dll. Just add reference to it.