Phalanger
PHP 5.4 compiler for .NET/Mono frameworks. Phalanger compiles legacy PHP code to MSIL while being fully compatible with PHP behavior.
Project maintained by DEVSENSE
Hosted on GitHub Pages — Theme by mattgraham
Note: There is a new, modern PHP compiler to .NET entitled Peachpie, which is being developed at the moment. Please see the Peachpie repository
By Jakub Misek, 11/22/2011
Today we have released sources of Phalanger 3.0 – the PHP compiler for .NET Framework. It represents a big step for PHP compatibility, .NET interoperability and overall performance.The main changes include PHP 5.3 namespace support, PHP constants using const keyword, the support for Mono on Linux, improvements that enable using Phalanger with numerous open-source PHP applications and several bugfixes.
EDIT: Phalanger 3.0 is released under Apache 2 license.
Installation package
EDIT: The installation package of Phalanger 3.0 (for Windows) can be downloaded from phalanger.codeplex.com.
List of main changes
CONFIGURATION CHANGES
- Assembly versions changed to 3.0.0.0 (PhpNet, php_.mng)
- Regenerated managed wrappers
- DynamicWrapper directory doesn’t need to be specified
- scripts are automatically recompiled if configuration changes
- license updated to Apache 2
- PHP 5.3 FEATURES
- Full PHP 5.3 namespace syntax and semantic
- aliases (use statement)
- parse-time full qualified name resolving (dynamically constructed qualified names ignore aliasing)
- Function call and constant use from within namespace as it is in PHP (first look in the current namespace, then in the global namespace)
- Compile time checks for type name duplicity
- CodeDOM redesigned for PHP namespace semantics
- Phalanger “import” statement deprecated
- Phalanger “import” statement allowed only in Pure mode, postpones the parse-time qualified name resolving
- callback can be specified as “CLASS::MEMBER”
- constant(), defined() recognizes “CLASS::CONST”
##MONO FUNCTIONALITY
- Fixed configuration loading
- Fixed FileSystem debug
- asserts for linux
- Fixed compiling of scripts in subdirectories on linux
##.NET INTEROPERABILITY
- MulticastDelegate automatically converted into callable PHP object (when passing from .NET to PHP)
- Dynamic operations on PHP objects (method call, properties get and set) (DLR)
- App_Code seamless integration
- PCRE
- regexps group names are allowed to start with a number
- preg_match_all() when used with PREG_PATTERN_ORDER should return groups even if there isn’t any match (PREG_SET_ORDER should return empty array)
- Fix of preg_match(): indexed groups with more than one digit added also as named group
- Fix of preg_match_all()
##COMPILATION
- Fixed emitting of namespaced empty statements
- Fix of compilation (tried to generate ghost stubs in already built base interface)
- Fix of creating long delegates (type name duplicity within a module exception)
- Debugging information fix for “IF … ELSEIF …”, “IF … IF … ELSE”
- Optimized CallSites container emitting, less types created and baked
- Fix of emitting optional argument with TypeHint, that is not used in the function
- Fix of abstract __construct declaration
- Fixed Eval in Eval (when deferred class is being compiled, causing autoload which creates another deferred class)
- Fixed __call() invocation when expecting a reference to be returned
##CODE MAINTENANCE
- Compiling Phalanger does not output any warnings
- phpinfo() displays Phalanger version and whether it runs in debug and x64
- some String.ToLower() replaced with CultureInfo.InvariantCulture.TextInfo.ToLower() (faster)
##OTHER FEATURES
- “libxml” extension stubs
- Removed php6 language features
- Implemented “const” keyword in global or namespaced code
- stripslashes () erases “\” if it’s last character, as it is in PHP
- Updated installer for new version, new output path
- Fix of DOM childNodes, when there is a whitespace
- base64_decode() with second parameter
- ob_gzhandler() crash fix when browser e.g. does not send “accept-encoding” header properly
- quoted_printable_encode() implemented
- User-friendly error message when trying to use native extensions in 64 process.
- Implicit conversion of PHP objects altered to comply with PHP ( $obj == 1 always )
- Binary and some unary operations support PHP objects
- join() with one argument
- Internal optimization avoiding of repetitious Dictionary resizing
- Internal optimization saving memory and garbage collector when declaring global function
- dynamic call of global function optimization avoiding lookup in dictionary
##SPL
- iterator_apply(), iterator_count(), iterator_to_array()
- interface OuterIterator, interface RecursiveIterator
##TESTS
- Tests for PHP namespaces
- New tests for PCRE
- Tests for const keyword
- Samples updated