What is CS2PHP?
cs2php is intended to help you in
- translating C# code to PHP,
- testing C# code before translation,
- managing libraries translated libraries
Three scenarios have been prepared for translation process:
- If you like PHP programming philosophy you can derive C# classes from
PhpDummyand use well-known methods like
file_get_contentsand many more.
- If you’re unwilling to use PHP (like me) and need substitute you’re in right place. Use special designed classes i.e.
Lang.Php.MysqlResultthat collect MySQL methods in one place and classes
Lang.Php.Filters.FilterInputthat serves PHP specific functionality in more attractive form.
- If you need to translate existing C# library cs2php offers you extendable translator that is able to convert methods (i.e.
empty), properties (i.e.
new DateTime) and classes (i.e.
All scenarios allows to take advantages of static type checking. C# code is compiled into dll before it is translated to PHP, so result code is more reliable.
Forget about mistyped variable or method names, forget about mistakes like = instead of ==.
Enums are used willingly. In example well known round function can be used
var a = round(value, 2, RoundMode.Up);
…using dedicated web server that simulates APACHE+PHP.
Just call http://localhost:11000/somefile.php and C# method associated with this url will be invoked. See results directly in web browser.
Divide your project into libraries, put them in preffered folder structure and forget about ‚include’ madness. Necessary files will be found and included behind the scenes.
in your C# projects by facade .NET libraries. Original PHP library will be downloaded and uncompressed during ‚compilation’ process.
Control translation process using attributes: change class, fields and method names. Manage namespaces and output file names.
Create WordPress plugins using Lang.Php.Wp extension.