Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Gsoc/2010/proposals/E4 PHP"

(New page: == 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...)
 
(PHP support into e4)
Line 27: Line 27:
 
}
 
}
 
</source>
 
</source>
 +
 
You could reference your PHP bundles using the "PHP-Bundle" header in the OSGi manifest. For example:
 
You could reference your PHP bundles using the "PHP-Bundle" header in the OSGi manifest. For example:
 
<source lang="xml">
 
<source lang="xml">
 
PHP-Bundle: scripts/bundle.json
 
PHP-Bundle: scripts/bundle.json
 +
</source>
 +
 +
The e4 support for PHP will provide a PHPFactory class to register extension points implemented in PHP.
 +
<source lang="xml">
 +
  <extension
 +
        point="org.eclipse.ui.actionSets">
 +
      <actionSet
 +
            label="Sample Action Set"
 +
            visible="true"
 +
            id="TestJavascriptPlugin.actionSet">
 +
        <menu
 +
              label="Sample &amp;Menu"
 +
              id="sampleMenu">
 +
            <separator
 +
                  name="sampleGroup">
 +
            </separator>
 +
        </menu>
 +
        <action
 +
              label="&amp;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>
 +
</source>
 +
 +
Subclassing and implementing Eclipse API will be done through annotation. PHP has runtime support for annotation with the addendum library [http://code.google.com/p/addendum].
 +
<source lang="php">
 +
<?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){}
 +
}
 +
?>
 
</source>
 
</source>
  

Revision as of 06:04, 9 April 2009

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 &amp;Menu"
               id="sampleMenu">
            <separator
                  name="sampleGroup">
            </separator>
         </menu>
         <action
               label="&amp;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

Schedule of Code and Deliverables

The project timeline is available on Google Calendar [2]

Back to the top