phpc compiling generates invalid namespaces

Discussion about the open-source Phalanger [?] project.

phpc compiling generates invalid namespaces

Postby Neokil » September 8th, 2015, 11:34 am

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
Neokil
 
Posts: 3
Joined: September 8th, 2015, 11:26 am

Re: phpc compiling generates invalid namespaces

Postby Jakub Misek » September 8th, 2015, 12:49 pm

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
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: phpc compiling generates invalid namespaces

Postby Neokil » September 8th, 2015, 1:08 pm

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?
Neokil
 
Posts: 3
Joined: September 8th, 2015, 11:26 am

Re: phpc compiling generates invalid namespaces

Postby Jakub Misek » September 8th, 2015, 1:35 pm

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
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: phpc compiling generates invalid namespaces

Postby Neokil » September 10th, 2015, 12:08 pm

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.
Neokil
 
Posts: 3
Joined: September 8th, 2015, 11:26 am

Re: phpc compiling generates invalid namespaces

Postby Jakub Misek » September 19th, 2015, 11:04 pm

all the functions you named are defined in PhpNetClasslibrary.dll. Just add reference to it.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague


Return to Phalanger project

Who is online

Users browsing this forum: No registered users and 19 guests

cron

User Control Panel

Login

Who is online

In total there are 19 users online :: 0 registered, 0 hidden and 19 guests (based on users active over the past 5 minutes)
Most users ever online was 256 on March 28th, 2024, 9:42 am

Users browsing this forum: No registered users and 19 guests