12

I have a business logic classes that are written in pure C# (without any specific things from this language) and I would convert this code into PHP. I can write my own parser, but think if I could someone did it before me.

Could you please tell me where can I find this kind of converter?

Ps. As I've written I use only plain C# programming in this language. Only arguments, declarations of variables, equations and control statements.

Tom Smykowski
  • 25,487
  • 54
  • 159
  • 236
  • 1
    Since I (regrettably) voted to close this question, I hope it will eventually be migrated to http://softwarerecs.stackexchange.com. – Anderson Green Feb 16 '18 at 03:13

5 Answers5

18

The jsc project can convert .net/C# to PHP for you.

  1. Overview: http://jsc.sf.net
  2. Source: http://jsc.sourceforge.net/examples/web/OrcasAvalonWebApplication/
  3. Example: http://jsc.svn.sourceforge.net/viewvc/jsc/templates/OrcasAvalonWebApplication/ alt text
Glorfindel
  • 21,988
  • 13
  • 81
  • 109
zproxy
  • 3,509
  • 3
  • 39
  • 45
7

I know you're hoping for someone who had experience but in case no one comes forward...

You might consider just copy and pasting the code into a PHP script and checking what breaks. Write a parser to fix that, run it across the entire script, and see what's the next thing that breaks. Continue until the script functions as expected.

If you're not using any of the more involved .Net classes I can't imagine you'll have too much trouble.

Spencer Ruport
  • 34,865
  • 12
  • 85
  • 147
3

There is just started project cs2php. Sources are available on https://github.com/isukces/cs2php and homepage is http://www.cs2php.com/ .

2

Are you asking for a tool to directly convert your C# code to PHP? I doubt there is one available and I'd be a little worried about using one (from what I've learnt of C# it's not easily transferrable to PHP).

Depending on the size of the project I'd be much more inclined to rewrite it. I did have a look but couldn't find anything (lots and lots of job requests though - looks like a business there =P).

Ross
  • 46,186
  • 39
  • 120
  • 173
  • I use only basic things like as I have written. I new before writing in C# that some day I will need to translate the code to other languages too. – Tom Smykowski Jan 13 '09 at 22:54
  • As long as you have fairly simple constructs, the code should translate over - it's just a matter of getting the syntax right. PHP doesn't support all of the advanced parts of C#, but it is catching up a bit - – William Nov 21 '13 at 15:03
2

You can now run your PHP code on .NET calling into your business clases using phalanger.codeplex.com

mcintyre321
  • 12,996
  • 8
  • 66
  • 103