Phalanger 3.0

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
    • 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

11 thoughts on “Phalanger 3.0

  1. Are you sure you have interpreted the GPL v2 correctly? From the text above you seem to be implying that anyone using Phalanger v3 to run PHP on .NET will have to open source their code. As running code on the server side is not the same as distributing the code, the GPL allows use without requiring the code to be released.

    http://stackoverflow.com/questions/4351119/if-i-use-gnu-gpl-code-with-my-own-server-side-code-do-i-need-to-open-my-server

  2. Hi, please can you give at least approximate date of releasing Windows Installer for this version of Phalanger? I`m really impatient, because this release looks pretty great and i want to try it on Nette Framework.

    Thank you for any information ;-) .

    • Hi, thanks for the interest!
      The installer is prepared already, we are just integrating few more features and testing …
      If you want the installer NOW :-) ping us on email info{youknow}phpcompiler.net.
      I’m just noting, as I know Nette needs PHP Reflection and FileInfo class, which is on the plan …

  3. Hello, is there a tutorial on how to install/configure phalanger 3.0 on Mono Linux ?

    thx

    • Not Yet, we are preparing installer of Phalanger 3.0 on Linux. We were waiting on Mono 2.10.7 which is necessary to run Phalanger 3.0. Since it is out now, it should be soon. To be notified follow us on twitter or facebook

  4. Thansk a lot. My main goal is to have wordpress running with phalanger 3.0 on mono linux.

    I installed mono 2.10.8 (last stable release). Then to get phalanger 3.0 i copied from my windows installation the bin and the wrappers to the linux bin. At this point i can run simple php pages and also php mysql connection working.

    Then i tried to install wordpress but i when installing in the second step i get to an error “System.MissingMethodException: Method contains unsupported native code
    at (wrapper managed-to-native) :_getFiberPtrId ()” due to the use of the native call to php4ts.dll (since i copied that from my windows installation)

    I also tried the function ‘phpinfo()’ and it gives me the same error but if i try ‘phpinfo(INFO_CONFIGURATION);’ then it gives me the phalanger information.

    I can wait to get your linux installer.

    thx

  5. Hello,

    You have to turn off all the native extensions in web.config. On Mono it’s possible to run only fully managed extensions, because our native extension manager is written in C++/CLI that currently isn’t implemented on Mono. But just with MySql it’s possible to run WordPress.

    If you want come to irc.freenode.net channel #Phalanger we can try what we can do with it:)

    Thanks