Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can write PHP application in linux platform.
However, I getting a request to explore the idea to run PHP application into .NET.

I have zero .NET knowledge.
So wondering, is it possible?

Is it advisable? Implication ? Or maybe I should just install a .NET to playaround first?

In short, zero code changes, except setup the PHP environment in .net.

Also, wondering, will this benefits from .net security?

The reason why I explore this idea is because Singapore government website must run on .NET (and I intend to save few bucks by not hiring dot net developers). I think the idea of application must run on .NET is absurd (a joke to me), just showing one of the "world-class" standard in Singapore :)

share|improve this question

closed as unclear what you're asking by gnat, BЈовић, GlenH7, MichaelT, Dan Pichelman Jul 28 '13 at 12:38

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

I'm confused as to your question. Are you trying to run a php application on a .net (Windows) platform? Yes you can do that. Or are you trying to migrate your application to a .Net environment, e.g. in which case you'd have to rewrite it and then you would "have" to run it on a Windows platform. – Klee Jul 26 '13 at 6:35
i mean to make the php code run on .net – ajreal Jul 26 '13 at 7:10
Your question doesn't make sense. You can run PHP on Windows, on an IIS server (or Apache, or anything else), but you can't turn PHP into .NET code without rewriting it. – Stephen Orr Jul 26 '13 at 7:38
@Stephen Orr: yes, you can. – Michael Borgwardt Jul 26 '13 at 7:49
@Klee: you also seem to be confused about .Net. It's a platform quite separate from the Windows OS. – Michael Borgwardt Jul 26 '13 at 7:51

So basically, what you want is to compile PHP to CIL, the bytecode language of .NET. This is in fact possible using Phalanger.

I have no experience using it, but I wouldn't expect existing PHP applications to run on it without problems, especially considering that most PHP apps rely heavily on extensions which are themselves not written in PHP. But that's an obvious problem, maybe the people working on Phalanger have come up with solutions.

share|improve this answer
oh, you have a point on the extensions – ajreal Jul 26 '13 at 8:06 can run a number of applications/CMSs on it. Like Wordpress. With GOOD benchmarks too. (I would be worried about scalability, thought) – ZJR Jul 26 '13 at 10:52
(fact is: php base functionality is large, and phalanger reimplements it, -or at least tries to- php non-standard binary extensions are rare and hard to keep current, while most custom setups/functionality is done trough the shell) – ZJR Jul 26 '13 at 10:56
@ZJR - Scalability should be pretty good as PHP is interpreted whereas CIL is much closer to machine code. – James Snell Jul 26 '13 at 12:40
@JamesSnell I was thinking more on the lines of "what to do when you have to throw more hardware in and add some replication". It certainly can be done, but the LAMP way differs so much from the MS Stack way, you might encounter issues with the company sysadmins along the way. (and yes most people won't run into this sort of trouble) – ZJR Jul 26 '13 at 18:04

It depends on what you mean by "run PHP application into .NET"...

a) You can run PHP sites in the server technology that .Net websites run on, its called IIS. This is just like running your PHP under Apache so there are no changes to your application. However, you are not really gaining anything from this as its just running the PHP application the same as Apache and the only reason people would do this is if their hosting solution is already using IIS.

b) If you mean you want to convert your PHP to a .Net application, I would suggest that you learn how ASP.Net works and port it across manually rather than using an automated tool. PHP and ASP.Net are very different beasts so they work in different ways. Besides, if you are expected to maintain the application in .Net then you will need to know how it works.

share|improve this answer
They don't necessarily need to use MVC however, your answer makes out this is the only option. – billy.bob Jul 26 '13 at 10:15
Good point, I have taken the MVC part out. It seems that since I have moved from WebForms to MVC that I have become unknowingly biased to MVC! – Penfold Jul 26 '13 at 10:28
.NET isn't just ASP. It's has a runtime that interprets CIL bytecode, and Phalanger doesn't translate PHP source code, it compiles to CIL just like Aspnet_compiler.exe does. You could maintain the PHP code just fine, except it would run in the .NET platform instead of the Zend engine. But of course that's just the PHP code, the extension library would pose problems, as would integration into the .NET server architecture. – Michael Borgwardt Jul 26 '13 at 10:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.