Fix For URL Auto Generate Bug in Eclipse PHP PDT Plugin

When you try to run/debug a PHP script, the “PHP Web Application” Run Configuration inserts the name of the PHP project into the URL. The auto-generate bug affects the “Launch URL” dialog. The project name in the auto-generated URL is unnecessary. Unchecking the “Auto Generate” option makes no difference. There is no way to turn it off.

Visual Studio does not behave this way. To top it all, I read one post where one fool requesting this specific feature/bug! Maybe it makes sense for MVC devs. Their projects look anemic without a million or two folders. I made several attempts in the past to learn PHP but this bug/annoyance turned me off each time. Curiously, this feature/bug was not present in Zend-PHP (trial), which is based on the same open source plugin.

Anyway, the offending behaviour is caused by the “org.eclipse.php.server.ui_[some-version-number].jar” plugin. You need to switch to the Eclipse Plugin Development perspective to work with it. After modifying the source, you can export your plugin project as a “jar” back to its original location. I would advise you to make a backup of the original plugin before you try this. Anyway, the files to be modified are:

  • /org.eclipse.php.server.ui/src/org/eclipse/php/internal/server/ui/launching/PHPWebPageLaunchShortcut.java (in function constractURL)
  • /org.eclipse.php.server.ui/src/org/eclipse/php/internal/server/ui/ServerLaunchConfigurationTab.java (in function formatFileName)

After the above changes, both dialogs become functional. My project name was PHPTest and it no longer gets inserted into the launch URL.

Changes to the source code of the PHP PDT plugin JAR file.

Changes to the source code of the PHP PDT plugin JAR file.

Run dialog of the Eclipse PHP plugin.

Run dialog of the Eclipse PHP plugin.

Autogenerate tab of the Run configuration.

Autogenerate tab of the Run configuration.

Advertisements
This entry was posted in software and tagged , , . Bookmark the permalink.

Make a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s