Page 1 of 1

compile dll

PostPosted: September 5th, 2016, 11:12 am
by danceoften
I am writing a c# managed dll for using it into an mvc web app.
I need to integrate some 3rd party php code in this dll:

1- can i compile a dll with mixed language code php + c#?
2- can i compile the 3rd party php code in a dll and reference in my own c# dll? (i just see web project and console app)
3- maybe i will just get or post to a php PAGE from my mvc app: can i add php page to a mvc app solution or should i have 2 separate projects?

what other options i have to interoperate from c# mvc app code ?

thank you in advance

Re: compile dll

PostPosted: September 9th, 2016, 8:57 am
by danceoften
In order to do what i wrote above, I installed Phalanger.

After installing i get this error at visual studio startup
after VS starts , php projects appear as 'the application is not installed'

---------------------------
Microsoft Visual Studio
---------------------------
The 'PHP Tools for Visual Studio Package' package did not load correctly.

The problem may have been caused by a configuration change or by the installation of another extension. You can get more information by examining the file 'C:\Users\ME\AppData\Roaming\Microsoft\VisualStudio\14.0\ActivityLog.xml'.

Restarting Visual Studio could help resolve this issue.

Continue to show this error message?
---------------------------
Sì No
---------------------------

Re: compile dll

PostPosted: September 9th, 2016, 11:32 am
by danceoften
update:
after the previous message we have the following:

---------------------------
Microsoft Visual Studio
---------------------------
The 'PhpTestPackage' package did not load correctly.

The problem may have been caused by a configuration change or by the installation of another extension. You can get more information by examining the file 'C:\Users\ME\AppData\Roaming\Microsoft\VisualStudio\14.0\ActivityLog.xml'.

Restarting Visual Studio could help resolve this issue.

Continue to show this error message?
---------------------------
Sì No
---------------------------

Re: compile dll

PostPosted: September 9th, 2016, 3:49 pm
by danceoften
update:
i solved and restored phptools working, just reinstalling it.
I do not see Phalanger working in Vs

second update:
i found out that I needed to uninstall phptools before installing phalanger.
this way i solved the errors.

Re: compile dll

PostPosted: September 12th, 2016, 7:35 am
by danceoften
danceoften wrote:I am writing a c# managed dll for using it into an mvc web app.
I need to integrate some 3rd party php code in this dll:

1- can i compile a dll with mixed language code php + c#?
2- can i compile the 3rd party php code in a dll and reference in my own c# dll? (i just see web project and console app)
3- maybe i will just get or post to a php PAGE from my mvc app: can i add php page to a mvc app solution or should i have 2 separate projects?

what other options i have to interoperate from c# mvc app code ?

thank you in advance


i found out that it's possible to use phalanger for this task and succeded installing it by first removing phptools.

i decided to move the original answer above in phalanger forum

Re: compile dll

PostPosted: September 12th, 2016, 8:31 am
by Jakub Misek
Phalanger is a PHP language compiler, it produces DLL file from PHP files.

1. no, like you can't mix C# and VB.NET, you can however reference DLL from a C# project.
2. yes
3. you can, by using PHP.Core.RequestHandler into web.config, all the .php files are compiled on web server lazily and you can make requests to them. However you can do the same with legacy php.exe.

I would recommend to compile .php files into a DLL (either by creating a separate project in VS or in a prebuild action of your ASP.NET website `phpc.exe /target:dll /out:website.dll /recurse:.`, reference this DLL and make use of Php.Core.Context API where you can simulate PHP runtime.

Re: compile dll

PostPosted: September 12th, 2016, 1:51 pm
by danceoften
Jakub Misek wrote:Phalanger is a PHP language compiler, it produces DLL file from PHP files.

1. no, like you can't mix C# and VB.NET, you can however reference DLL from a C# project.
2. yes
3. you can, by using PHP.Core.RequestHandler into web.config, all the .php files are compiled on web server lazily and you can make requests to them. However you can do the same with legacy php.exe.

I would recommend to compile .php files into a DLL (either by creating a separate project in VS or in a prebuild action of your ASP.NET website `phpc.exe /target:dll /out:website.dll /recurse:.`, reference this DLL and make use of Php.Core.Context API where you can simulate PHP runtime.


Thank you for your support, I decided i will go with solution 2:
I will compile third party php code in a managed dll and then reference it from my code (c# dll).

for doing this i found some instruction in an article :

http://tomasp.net/blog/aspnettexy.aspx/

where is suggested to just remove includes and to statically call defines in constructor.
so i modified the php code accordingly.

My question now is, wich template should i choose for having a managed dll ?
in the article it mention a pure mode but i cannot find this setting in the project properties when choosing the phalanger/class library.

Thank you again for the phalanger implementation of php under .net

Re: compile dll

PostPosted: October 2nd, 2016, 7:47 pm
by Jakub Misek
Good.

Phalanger/Class Library is a Pure mode project.