running on custom webserver

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

running on custom webserver

Postby kaiwachter » January 20th, 2014, 10:22 am

HI Guys,
i am new to phalanger but it sounds absolutely interesting.
We have developed a huge application runnning on a custom webserver (not IIS or Apache). it is 100% .Net).
One case is to host Webpages. we have integrated PHP by FAST CGI currently.
How can i run Web applications build in PHP with phalanger instead of PHP.
Is there a way to run the PHP files like call php.exe?
Any code sample is appreciated.

best regards
Kai
kaiwachter
 
Posts: 2
Joined: January 20th, 2014, 10:16 am

Re: running on custom webserver

Postby Jakub Misek » January 20th, 2014, 2:46 pm

Hi,

Phalanger has built-in request handler which caches/compiles/runs PHP file requested by web server;

In IIS the configuration is following:
Code: Select all
<system.webServer>
    <handlers>
      <add name="PhalangerHandler" path="*.php" verb="*" type="PHP.Core.RequestHandler, PhpNetCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0a8e8c4c76728c71" resourceType="Unspecified" preCondition="integratedMode" />
    </handlers>
  </system.webServer>


You can reuse/call this handler in order to process web request.

To run php script file from command line, you have to first compile it
Code: Select all
phpc.exe /target:exe file.php
and then run it
Code: Select all
file.exe
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2085
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: running on custom webserver

Postby kaiwachter » January 20th, 2014, 3:06 pm

wow thats cool.
do you Need to set all the PHP variables also as Environment variables like we do that for the phpcgi file?

something like:

Code: Select all
            Process process = new Process();

            process.StartInfo.UseShellExecute = false;
            process.StartInfo.CreateNoWindow = true;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError = true;
            process.StartInfo.FileName = "index.exe";
            process.StartInfo.StandardOutputEncoding = System.Text.Encoding.GetEncoding("ISO-8859-1");
            var variables = CgiHelper.GetEnvironmentVariables(irequest, path, scriptName);

            foreach (var item in variables)
            {
               process.StartInfo.EnvironmentVariables.Add(item.Key, item.Value);
            }
  // Start the process
            process.Start();


best regards
Kai
kaiwachter
 
Posts: 2
Joined: January 20th, 2014, 10:16 am

Re: running on custom webserver

Postby Jakub Misek » January 23rd, 2014, 11:18 am

when running web server, you don't want to run the .exe for every request (in case of .NET it would make huge overhead)

Please take a look on PHP.Core.RequestHandler class. You can reproduce steps done there. The only catch is, it makes use of System.Web.HttpContext and most of variables and states are filled from it. Including session handling and other web-related routines.

If you would like to use Phalanger in the context of your custom web server, without valid HttpContext instance, you might lose some features. (some functions rely on this class, checks HttpContext.Current etc.)
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2085
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: running on custom webserver

Postby Jakub Misek » January 23rd, 2014, 11:20 am

Variables are initialized on every request in PHP.Core.AutoGlobals, method Initialize. They come from System.Environment.GetEnvironmentVariables(), HttpContext.Request.ServerVariables, Request.QueryString, Request.Cookies
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2085
Joined: January 4th, 2012, 2:42 pm
Location: Prague


Return to Phalanger project

Who is online

Users browsing this forum: No registered users and 2 guests

User Control Panel

Login

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 5 minutes)
Most users ever online was 89 on October 15th, 2018, 4:06 pm

Users browsing this forum: No registered users and 2 guests
Phalanger