eclipse-pdt / pdt

PHP Development Tools project (PDT)
https://eclipse.org/pdt
Eclipse Public License 2.0
188 stars 46 forks source link

PHP Built-in Server tries to use project directory as document root #271

Open hcgpalm opened 4 months ago

hcgpalm commented 4 months ago

Describe the bug In recent versions of PDT, a project workspace directory is naively used as the document root for the PHP Built-in Server. I.e. the server starts a process like: /usr/bin/php -S 127.0.0.1:8180 -t /home/joe/myworkspace/myphpproject

This breaks a lot of the WST Server functionality:

  1. When the project Location differs from its Path (for example when you create the project using the option "Create project at existing location"), the project workspace directory doesn't actually contain the project files (just the metadata). Hence nothing is served.
  2. If you add multiple php projects to a server, only one of them is actually served.
  3. Run As->Run on Server on an object doesn't work even in the naive case as WST assumes a context root of localhost:port/project_name/ rather than localhost:port/.
  4. PDT assumes that the project file structure exactly corresponds to the structure of the served documents. This is supposed to be defined by the Deployment Assembly (in WST terminology). Admittedly, there is no such thing in a PDT project, but in older versions of PDT it seems to be implicitly defined as the aggregate of the projects source folders. I.e. if you had the files /src/a.php and /htdocs/b.html and both /src and /htdocs are defined as source folders, the files used to be served as /a.php and /b.html, but are now served as /src/a.php and /htdocs/b.html.

It appears that this works (more or less) fine in PDT 7 and is broken in PDT 8. More specifically: Works: PHP Development Tools (PDT) 7.2.1.202112011741 org.eclipse.php.feature.group Eclipse PDT Broken: PHP Development Tools (PDT) 8.1.0.202307170929 org.eclipse.php.feature.group Eclipse PDT

I'm pretty sure that issue #68 is at least partly to blame.

Describe the eclipse environment Eclipse version: eclipse-php-2024-03-R PHP Development Tools (PDT) 8.2.0.202311292129 org.eclipse.php.feature.group Eclipse PDT

Describe your system

To Reproduce Steps to reproduce the behavior:

  1. Create PHP project 'p1'
  2. Inside 'p1', create files /a/a.php and /b/b.php
  3. Edit project properties of 'p1', under PHP Build Path, remove 'p1' and add 'p1/a' and 'p1/b'
  4. Create PHP project 'p2'
  5. Inside 'p2', create file /c/c.php
  6. Edit project properties of 'p2', under PHP Build Path, remove 'p2' and add 'p2/c'
  7. Create a new Server of type PHP Built-in Server
  8. Add 'p1' and 'p2' to the Server
  9. Start the Server

Expected behavior

  1. Expect a.php to be available on http://localhost:8180/p1/a.php
  2. Expect b.php to be available on http://localhost:8180/p1/b.php
  3. Expect c.php to be available on http://localhost:8180/p2/c.php
  4. Right-click a.php, choose Run As...->Run on Server. Expect Eclipse to open a browser window showing a.php on URL http://localhost:8180/p1/a.php (this actually doesn't work in PDT 7 either).