Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Convert PHP to .NET For Beginners [closed]

Tags:

c#

.net

php

asp.net

What options do I have for converting PHP to C#/ASP.NET?

I had a really tough time finding information on this, so I've created this question/answer to be a one stop shop for those of you who have also hit this kind of stumbling block.

In short, I will explain the different tools I'd found, what worked out for me, and also link you to some conversion guides.

like image 269
sabastienfyrre Avatar asked Jul 07 '15 14:07

sabastienfyrre


1 Answers

Microsoft's PHP to ASP.NET Migration Assistant

http://www.asp.net/downloads/archived-v11/migration-assistants/php-to-aspnet

The Good:
Microsoft has a PHP to ASP.NET Migration Assistant! It's not perfect, but does fairly well despite the differences inherent in the languages. It doesn't create the codebehind for you, but rather, puts generated C# in a script tag in an .aspx file.

The Bad:
It was a challenge getting this working because it's a little old and required me to install Microsoft .NET Framework 1.1 Redist, and Microsoft .NET Framework 1.1 Service Pack 1 in VS2010 in order to install the Migration Assistant itself.

Some of you may have trouble with these Framework installations. If you do, I found a handy dandy guide right here: http://answers.microsoft.com/en-us/windows/forum/windows_7-windows_programs/how-to-install-net-framework-11-in-windows-7-64/eb1e6232-e874-432e-ab43-17660e25e43d?page=1&tm=1345067625733

Also, after I'd gotten it to install, it wasn't appearing in my conversion tools in VS2010. So, I had to do this: http://forums.asp.net/t/1530808.aspx?no+PHP+to+ASP+NET+Migration+Assistant+in+MS+Visual+Studio+2008

Re: no PHP to ASP.NET Migration Assistant in MS Visual Studio 2008 Apr 11, 2012 10:15 PM|LINK

Once you install the Migration assistant open a DOS window thru CMD.exe In the dos window : Change directory to: CD C:\Documents and Settings\spatel>cd C:\Program Files\Microsoft Corporation\PHP t o ASP.NET Migration Assistant Then type in the following and click enter : PHPCONVERT.EXE C:\PhpSourceDirectory /Out C:\ASPoutputdirectory Open the project from within Visual Studio 2008 and choolse to convert. Note: in the step 3 above C:\PhpSourceDirectory is where I had my PHP files stored and similarly C:\ASPoutputdirectory is where I wanted my ASP.net output to go.

PHPCONVERT.EXE has other options that you can explore by typing in PHPCONVERT.EXE /?

When I saw this forum ...I gave hope but PHPCONVERT.EXE was a life saver , my work effort reduced by 90% for the conversion.

The latest version of the convertor is available @ http://www.asp.net/downloads/archived-v11/migration-assistants/php-to-aspnet

I'll note that these command lines needed tweaking for an x86 machine. PHPCONVERT.EXE might be in Program Files(x86) instead of Program Files.

Overall, it took some time, but that's what I had to do to get it working, I hope that this helps you out of your current bind.


Phalanger - A PHP Compiler for Visual Studio

If you want PHP to compile in your .NET app try Phalanger
http://www.php-compiler.net/

I was interested in this, but ultimately decided against it due to licence fees. However, they are on GitHub if you want to check it out. https://github.com/DEVSENSE/Phalanger


Converting PHP Yourself

Here are some resources for learning PHP basics, and a bare-bones conversion guide.
http://learnxinyminutes.com/docs/php/
http://www.codestore.net/store.nsf/unid/BLOG-20100603-0518


Thanks everyone! All the best to you, and happy coding.

like image 181
sabastienfyrre Avatar answered Oct 22 '22 15:10

sabastienfyrre