Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Gsoc/2010/proposals/E4 PHP
Contents
PHP support into e4
This is a 2009 Google Summer of Code project proposal.
Project description
The aim of this project is to leverage PHP/Java bridge for adding a PHP support into e4, the next generation of the Eclipse Platform. e4 has already a support for writing plug-ins in JavaScript using Rhino capabilities to interact between JavaScript and Java. The PHP Bundles and the Extension Registry Support will be identical to the one for the JavaScript support. The second step is to make this project get real around the PHP community by extending PDE to support PHP Plug-ins. This includes:
- Manifest validation
- Wizards for PHP Plug-in creation
- Static code Analysis to resolve bundle/package dependencies
- Writing extension points in PHP
- Evangelism to the PHP community through a screencast.
The PHP Development Toolkit (PDT) project provides Eclipse for the PHP language. PDT and DLTK combined define more than 30 extension points, allowing PHP developers to integrate their own PHP frameworks and tools.
However, PHP developers are often not familiar with Java and they need to use PHP not only for dynamic capabilities but also to integrate PHP-written libraries inside Eclipse. Using PHP as a runtime language for plug-in is also a great opportunity to script development workflows.
The aim of this project is to leverage PHP/Java bridge for adding a PHP support into e4, the next generation of the Eclipse Platform and to extend PDE to support the creation of PHP plug-ins.
Using the e4 recipe
E4 JavaScript support defines OSGi bundles in JSON format that can be used to define a JavaScript bundle's metadata. We can reuse this mechanism for PHP bundles:
{ "BundleSymbolicName":"org.eclipse.e4.php.examples.helloworld.phpbundle", "BundleVersion":"1.0", "ScriptPath":"helloworld.js" }
You could reference your PHP bundles using the "PHP-Bundle" header in the OSGi manifest. For example:
PHP-Bundle: scripts/bundle.json
The e4 support for PHP will provide a PHPFactory class to register extension points implemented in PHP.
<extension point="org.eclipse.ui.actionSets"> <actionSet label="Sample Action Set" visible="true" id="TestJavascriptPlugin.actionSet"> <menu label="Sample &Menu" id="sampleMenu"> <separator name="sampleGroup"> </separator> </menu> <action label="&Sample Action" icon="icons/sample.gif" class="org.eclipse.e4.php.registry.PHPFactory:HelloWorld" tooltip="Hello, Eclipse world" menubarPath="sampleMenu/sampleGroup" toolbarPath="sampleGroup" id="testjavascriptplugin.actions.SampleAction"> </action> </actionSet> </extension>
Subclassing and implementing Eclipse API will be done through annotation. PHP has runtime support for annotation with the addendum library [1].
<?php /** * @Interfaces({'org.eclipse.ui.IWorkbenchWindowActionDelegate'}) */ class HelloWorld { private $window; public function run($action) { $messageDialog = Java('org.eclipse.jface.dialogs.MessageDialog'); $messageDialog->openInformation($this->window->getShell(), 'TestPHPPlugin', 'Hello e4 world'); } public function init($window) { $this->window = $window; } public function dispode(){} public function selectionChanged($action, $selection){} } ?>
PHP and Java chatting together
Using a PHP/Java bridge with EPL-compatible license, PHP can interact with Java on a single JVM instance, allowing it to script the Eclipse environnement. Java is capable of calling PHP code and interact with PHP objects through proxy classes dynamically generated. A shared runtime stack between PHP and Java allows both languages to exchange seamlessly parameters and returned values.
PDE support for PHP plug-ins
By Extending File:Bundlebuilder:Bundle builder
Schedule of Code and Deliverables
The project timeline is available on Google Calendar [2]