Phalanger Ideas Page

Introducing full-featured PHP runtime & compiler for .NET/Mono frameworks. Phalanger is modern open-source implementation of PHP, compatible with the vast array of existing PHP code. In addition Phalanger gives PHP-application developers lot of new possibilities; like improving the performance, allowing to use modern environments or taking advantage of seamless .NET integration.

Contents

1. Guidelines
1.1. Mentors
1.2. Requirements
2. Ideas
2.1. Linux & Mono
2.1.1. Project: Monodevelop PHP plugin
2.1.2. Project: Phalanger package
2.1.3. Project: Moonlight 4.0 support
2.1.4. Project: OpenGL API for PHP
2.1.5. Project: Native Linux library interoperability
2.1.6. Project: Native PHP library interoperability
2.2. Windows & .NET
2.2.1. Project: Silverlight 4.0 Support
2.2.2. Project: COM interoperability
2.2.3. Project: DirectX API for PHP
2.3. Mobile Devices
2.3.1. Project: Ensure MonoDroid running PHP
2.3.2. Project: Ensure MonoTouch running PHP
2.3.3. Project: Build PHP application running on WindowsPhone7
2.4. Compatibility & New Features
2.4.1. Project: Lambda Functions and Closures
2.4.2. Project: Late Static Binding
2.4.3. Project: Traits
2.4.4. Project: Implement PHP Extensions
2.4.5. Project: SPL Library
2.4.6. Project: PHP Reflection
2.4.7. Project: Run PHP Applications and Frameworks on .NET
2.4.8. Project: Language Integrated Query to .NET
2.4.9. Project: PHP 5 native extensions interoperability
2.5. Runtime Performance
2.5.1. Project: Local variables optimization
2.5.2. Project: Mono Performance

1. Guidelines

1.1. Mentors

Mentor Contact
Miloslav Beňo Email: milkob@gmail.com, Skype: miloslavbeno
Jakub Míšek Email/XMPP: jmisek@gmail.com, MSN: jakubmisek@volny.cz, ICQ: 170595796, Skype: ekubik
Tomáš Petříček Email/MSN: tomas@tomasp.net, Web/Blog: http://tomasp.net/

Feel free to contact us with your ideas, questions or suggestions.

1.2. Requirements

The Phalanger project is built on the .NET technology, mostly written in C# language. Occasionally some parts are written in C++/CLI and IL languages. Participating on our project requires knowledge of .NET runtime and C# language. Optionally it would help to understand compilers, .NET/Mono internals and interoperability between managed and native code on Linux or Windows.

2. Ideas

2.1. Linux & Mono

The Phalanger project is built on the .NET platform with respect to Mono implementation. This allows users to take advantage of PHP language simplicity on all the .NET platforms. Following projects are great opportunities to learn PHP and Mono integration on Linux.

2.1.1. Project: Monodevelop PHP plugin

Design and develop plugin for Monodevelop IDE that enables PHP projects for .NET – PHP console application and PHP web site. It can be easily done by using the Phalanger compiler & runtime. Optionally you can implement syntax highlighting features, propose Code Sense functionalities etc.

Expected Results: Installable Monodevelop plugin that enables PHP projects like PHP console application and PHP web site. PHP code can be written, compiled by Phalanger and resulting .NET assembly debugged right in the environment.
Required Skills: C#, Monodevelop, PHP
Complexity: Medium
Mentor: Jakub Míšek

2.1.2. Project: Phalanger package

Phalanger comes with simple installation package for Windows that automatically copies, registers and configures Phalanger compiler and runtime. This would help a lot to community using Linux; a package with auto-update ability that installs prerequisites like Mono, installs Phalangers binaries and configures it to run immediately as a web server or as a standalone PHP compiler for .NET.

Expected Results: Phalanger Linux installation package.
Required Skills: Mono, Linux packages
Complexity: Low
Mentor: Jakub Míšek

2.1.3. Project: Moonlight 4.0 support

Phalanger was able to compile PHP code as a Silverlight/Moonlight 2.0 application already. This project takes into account Moonlight 4.0 platform. However the Silverlight 2.0 support was broken. Student can update and fix the Phalanger for Silverlight and ensure it works on Moonlight 4.0 too.

Expected Results: Moonlight 4.0 application built from PHP code using Phalanger.
Required Skills: Mono, Moonlight, C#, occasionally IL.
Complexity: High
Mentor: Miloslav Beňo

2.1.4. Project: OpenGL API for PHP

There are many managed wrappers allowing developing of OpenGL application in C# (or any other .NET family language). Since Phalanger introduces PHP language into the family of .NET languages, it is possible to build OpenGL application in PHP now. Student can easily reference managed OpenGL wrapper within its PHP project and take advantage of all of its .NET objects.

Expected Results: OpenGL managed application written in PHP language.
Required Skills: OpenGL, C#
Complexity: Medium
Mentor: Jakub Míšek

2.1.5. Project: Native Linux library interoperability

There is already an extension that allows using of .NET classes in classic PHP. Since Phalanger is natively built to integrate PHP with .NET, this interoperability works seamlessly without a need of such extension. However there is no similar extension that allows using of native C/C++ functions from managed environment. This project takes into account interoperability of managed Mono world and world of native C/C++ libraries. Create managed library running on Mono/Linux providing object oriented access to functions in native C/C++ libraries. Student can take advantage of dynamic environment provided by Phalanger to create wrapping functions and classes during runtime.

Expected Results: Managed library that allows calling functions from any C/C++ library. Design this library as Phalanger extension providing object oriented way to access native libraries.
Required Skills: C++, Mono, Mono interop, C#
Complexity: High
Mentor: Miloslav Beňo

2.1.6. Project: Native PHP library interoperability

A lot of libraries were written for PHP as native extensions in C language. This project targets the interoperability possibilities of native PHP extensions and managed code running on Mono. You can load native PHP extension and read its native functions/classes and constants. Using built-in Mono C++ interop it could be possible to generate managed library exposing these functions/classes and constants that call internally corresponding representation in native linux PHP extension. This managed wrapper should be easily usable in any managed application running on Mono. Student can use the similar solution already built for native Windows PHP extensions.

Expected Results: Generator of managed libraries that wrap functionality of native Linux PHP extension.
Required Skills: C++, C#, IL, Mono, Mono interop.
Complexity: Very High
Mentor: Miloslav Beňo

2.1.6.1. Project: Linux extension support

Some PHP extensions require to use the PHP core and current runtime state itself (e.g. to collect local variables, look for declared classes, call ZEND API etc.). To enable seamless and proper support of native PHP extensions there can be designed so called extension support for PHP extensions. This relies on technique known from Windows called DLL hijacking. The actual PHP core library is replaced with different library with the same interface that catches requests of the library and responses with the information obtained from the Phalanger runtime. Student can use the similar solution already built for native Windows PHP extensions. The solution is not expected to be fully working; we are expecting a sort of proof of concept.

Expected Results: Generator of managed library that wrap functionality of native Linux PHP extension (see above). Moreover calls from the extension to PHP core must be catch and forwarded to actual managed runtime that serves back faked information.
Required Skills: C++, C#, IL, Mono, Mono interop.
Complexity: Very High
Mentor: Jakub Míšek

2.2. Windows & .NET

On Windows Phalanger is still little bit more usable than on linux. Since it is more complete, and available also with integrated development environment, there are greater possibilities of experimenting and integrating with existing technologies.

2.2.1. Project: Silverlight 4.0 Support

Phalanger was already modified to allow compiling and running PHP code on Silverlight 2.0. However the support was not maintained and was broken a little. Student can port an existing code by using Silverlight 4.0 SDK and fix features working on full .NET and not working on Silverlight CLR. Student can use many documented examples of Silverlight 2.0 applications written in PHP already.

Expected Results: Silverlight 4.0 application built from PHP code using Phalanger.
Required Skills: C#, Silverlight 4.0, compilers and IL intuitively.
Complexity: Medium to High.
Mentor: Miloslav Beňo

2.2.2. Project: COM interoperability

PHP extension COM allowing users to interact with .NET and COM objects is very inefficient way of accessing such objects in PHP. Since Phalanger interoperates with .NET by design seamlessly, the COM extension was not implemented. However due to 100% compatibility issues with classic PHP applications the support can be added. Moreover the extension allows accessing COM objects by ID, which Phalanger can’t. This project is interesting in its possibilities of integrating COM objects into dynamic environment. Student can design a way of accessing COM objects that simplifies its usage a lot – thanks to dynamic environment it can be easier than in C#.

Expected Results: COM and NET classes that are known from PHP extension COM. The classes have to encapsulate .NET types in the form of Phalanger object.
Required Skills: C#
Complexity: Medium. Student can learn object model of interoperability between static .NET world and dynamic PHP world.
Mentor: Jakub Míšek

2.2.3. Project: DirectX API for PHP

There are many managed wrappers allowing development of DirectX application in C# (or any other .NET family language). Since Phalanger introduces PHP language into the family of .NET languages, it is possible to build DirectX application in PHP now. Student can easily reference managed DirectX wrapper within his PHP project and take advantage of all of its .NET objects.

Expected Results: DirectX managed application written in PHP language.
Required Skills: DirectX API, C#, e.g. WindowsAPICodePack
Complexity: Medium
Mentor: Jakub Míšek

2.3. Mobile Devices

Taking advantage of Mono giving us a great possibilities of integrating PHP language with all the platforms supported by Mono, even with mobile devices.

2.3.1. Project: Ensure MonoDroid running PHP

Phalanger compiles PHP code into managed application that runs on Mono platform seamlessly. Using MonoDroid student can build an application in PHP, even using .NET methods, compile it with Phalanger, and deploy it onto Android OS running MonoDroid.

Expected Results: An application written in PHP running on an Android device.
Required Skills: Mono, C#
Complexity: Low
Mentor: Tomáš Petříček

2.3.2. Project: Ensure MonoTouch running PHP

Phalanger compiles PHP code into managed application that runs on Mono platform seamlessly. Using MonoTouch student can build an application in PHP, even using .NET methods, compile it with Phalanger, and deploy it onto OS X running MonoTouch.

Expected Results: An application written in PHP running on OS X device.
Required Skills: Mono, C#
Complexity: Low
Mentor: Tomáš Petříček

2.3.3. Project: Build PHP application running on WindowsPhone7

Windows Phone 7 applications are completely managed, running on modified Silverlight runtime. Phalanger is able to compile PHP code into managed IL code. Also it seamlessly allows usage of .NET objects and methods. Since it would be possible to write application in PHP language and compile it with modified Phalanger compiler built on WP7 SDK.

Expected Results: An application written in PHP running on Windows Phone 7 device.
Required Skills: C#, Silverlight, XAML
Complexity: Very High. Also Phalanger can be extended with Code DOM for XAML.
Mentor: Tomáš Petříček

2.4. Compatibility & New Features

Phalanger is completely new full implementation of PHP language. It is almost complete and offers full range of PHP features plus many new introduced only in Phalanger to allow easy seemless interoperability with .NET runtime. Still there are missing functionalities that would improve the value of the project.

2.4.1. Project: Lambda Functions and Closures

Lambda functions are construct originating from domain of functional languages which enable developers to declare and use functions as first class values. In brevity, lambda function is special kind of object which can be called. Closures are objects used to enable lambda functions to access local variables of functions that they are declared in. Both lambda functions and closures were introduced in PHP 5.3.

Expected Results: Implementation of both compilation and runtime for lambda functions and closures.
Required Skills: C#, IL Emit, Compiler Design (intermediate)
Complexity: High.
Mentor: Tomáš Petříček

2.4.2. Project: Late Static Binding

Late static binding is a new feature introduced in PHP 5.3, which makes it possible to bind the static members in a function based on class which is used to call it. Imagine classes A and B, both with static member foo, and A in addition having function bar, which only prints result of foo() call to output. If self::foo() is called in bar(), A::bar() calls A::foo() and B::bar() also calls A::foo(). If you use static::foo() instead, A::bar() calls A::foo() and B::bar calls B::foo(). This can be quite useful for static functions which do common task using static members which can change in the derived classes.

Expected Results: Implementation of both compilation and runtime for late static binding.
Required Skills: C#, IL Emit, Compiler Design (basics)
Complexity: Medium to high. Student will have to learn part of Phalanger reflection and internal compilation structures to implement this efficiently.
Mentor: Tomáš Petříček

2.4.3. Project: Traits

Phalanger is easily updatable compiler of PHP language. Traits is a new PHP 5.4 feature, that should be implemented into Phalager runtime and compiler to keep compatibility with latest PHP applications.

Expected Results: PHP 5.4 Traits support in Phalanger.
Required Skills: C#, IL Emit, Compiler Design (advanced)
Complexity: High.
Mentor: Miloslav Beňo

2.4.4. Project: Implement PHP Extensions

Phalanger was originally targeted to be compatible with PHP 4.X and compatibility with 5.X versions was maintained only partially. Many extensions, which were previously optional, were bundled to PHP. Currently, Phalanger supports PHP 4.X versions using native Extension Support. However, these extensions were changed and updated since, so Phalanger does not support current version. Since Native Extension Support does not fully support PHP 5 extensions and generally this support suffers from performance drawbacks. For example it would be great if Phalanger’s Class Library was extended by following built-in extensions:
  • BCMath - Extension enabling use of arbitrary-precision mathematics.
  • FTP - Extension providing functions for communication using File Transfer Protocol.
  • IconV - Extension, which implements functions for easier writing of multilingual scripts.
  • libXML - Extension which provides basic functions to many other XML-related extensions.
  • ODBC - Extension which implements functions of ODBC and Unified ODBC (database with semantics derived from ODBC).
  • WDDX - Extension providing functions for using Web Distributed Data Exchange (WDDX) data interchange mechanism.
  • SQLite - Extension providing function for using SQLite lightweight database.
  • XML - Extension which allows implementation of XML Parsers.
  • ZLib - Extension which enables transparent reading and writing of gzip compressed files.

Expected Results: Implementation of one or more extensions (depending on complexity).
Required Skills: C#, basic knowledge of involved technology.
Complexity: Low to high. Depends on the specific extension, some may be simple mapping of .NET library to PHP function behavior, some require protocol reimplementation because of unavailability of Windows-compatible libraries or licence issues (e.g. proprietary or GPL).
Mentor: Jakub Míšek

2.4.5. Project: SPL Library

SPL library contains many functions and classes that provide PHP with some basic data structures, iterators, interfaces, exceptions and other functionality. Phalanger implements most of this, though there are many areas, which remain unimplemented – largest part being SPL data structures. There are two possible approached to this – student can either implement this in C# or implement it as PHP/CLR Pure library, the latter approach being used currently.

Expected Results: Implementation of remaining functions and classes and fixing the existing ones to be compatible with current implementation.
Required Skills: C#, PHP, knowledge of common data structures and algorithms.
Complexity: Low or Medium.
Mentor: Miloslav Beňo

2.4.6. Project: PHP Reflection

Phalanger has its own design and implementation of Reflection layer which was prepared with .NET interoperability and compilation in mind – this reflection layer is used by Phalanger runtime for many dynamic operations. The point of this project is to map interface used by PHP to existing Phalanger reflection layer. This may prove to be difficult as runtimes of Phalanger and PHP work very differently.

Expected Results: Implementation of Reflection classes which work accordingly with PHP implementation.
Required Skills: C#, PHP runtime (familiar).
Complexity: High.
Mentor: Miloslav Beňo

2.4.7. Project: Run PHP Applications and Frameworks on .NET

There are many various open-source applications and frameworks written in PHP. While Phalanger is already able to run many (e.g. Wordpress, Drupal 6.2, phpBB and MediaWiki 1.6) without any problem, it’s always good to have more compatible and reliable software. One way of ensuring this is to use applications or frameworks and resolve issues that are encountered. If you have favorite applications or frameworks, which you will like to run on Phalanger (e.g. because of increased performance or .NET integration), you can test it and resolve issues which are revealed in the process.

Note: currently PHP projects requiring extensions that has not been reimplemented to .NET yet can run on Windows/Phalanger only.

Expected Results: Working application on Phalanger and resolved bugs for one or multiple projects, or list of incompatibilities for projects with more issues.
Required Skills: C#, PHP
Complexity: Low to High. This depends on actual issues.
Mentor: Miloslav Beňo

2.4.8. Project: Language Integrated Query to .NET

Phalanger already defines extended syntax for Language Integrated Queries (LINQ). However currently the Phalanger compiler and runtime only supports LINQ when working with PHP arrays. We have some ideas on how to extend the support to include other .NET LINQ providers based on IQueryable, but most of the interesting work remains to be done.

Expected Results: Full support of Language Integrated Queries working with .NET IQueryable providers.
Required Skills: C#, .NET, Compilers
Complexity: High
Mentor: Tomáš Petříček

2.4.9. Project: PHP 5 native extensions interoperability

Phalanger supports standard PHP4 extensions using DLL injection technique. However this component is outdated and it does not support PHP5 extensions. The goal of this project is to finish the support for PHP5 extensions. It is needed to update internal data structures for current version of Zend engine, implement missing support for streams and other features. The component uses very interesting technique of hijacking PHP core by simulating its C exports, and thanks to CLI it comunicates with .NET Phalanger Core.

Expected Results: Working standard PHP5 extensions from Phalanger.
Required Skills: C#, C++/CLI
Complexity: Very High
Mentor: Jakub Míšek

2.5. Runtime Performance

Increasing the performance is one of the main purposes of the project Phalanger. Currently Phalanger runs standard PHP applications with great performance, faster than the fastest PHP cached solutions. Now it is time to fix several latest performance bottlenecks.

2.5.1. Project: Local variables optimization

Phalanger improves performance of PHP applications by analysis and generating standard .NET assemblies. Local variables are translated into standard local variables living on stack if possible (in contrast to PHP, which keeps locals in a hash table).
However there is missing type analysis, so every local variable is of type Object. It means value types have to be boxed (results in additional allocation on heap and overuse of Garbage Collection). Also every usage of a local variable has to rely on dynamic type check, because the type is not known in compile-time.
Student can implement code flow graph or simpler type hinting/analysis to predict variable type if possible. Then it would be possible to update compiler to work with this new information properly, generate typed local variable declaration, read and write locals without dynamic type check and boxing overhead.

Expected Results: Code flow analysis and infer variables type.
Required Skills: C#, PHP, Compilers
Complexity: High
Mentor: Jakub Misek

2.5.2. Project: Mono Performance

Mono is intended to behave as Microsoft .NET implementation. Phalanger is currently being built on Microsoft platform and is taking advantage of many .NET features. So it already helped to found many differences between .NET and Mono. There is interesting possibility of comparing the performance of large-scale application like Phalanger on two different platforms. Student can make use of many existing PHP and Phalanger benchmarks. Student should find differences and fix Phalanger to behave efficiently on both platforms. Also dramatic performance issues of Mono can be reported to community, which can help to boost all the applications running on Mono.

Expected Results: Comparison of Phalanger performance on .NET and Mono using several open-source PHP applications and benchmarks.
Required Skills: C#, PHP
Complexity: Low to Medium.
Mentor: Jakub Míšek

Last edited Mar 21, 2012 at 3:09 PM by jakub, version 3

Comments

No comments yet.