Monday, March 7, 2022

[FIXED] Eclipse with composer problem with "run on server", ok with "PHP CLI Application"

Issue

Hi I have a project that uses composer to handle mongo libraries, if I debug with a "test cli application" as console application it works fine, as soon as I try to run it as "run on server" it "looses" autoload.php. The server is a native eclipse's php server

my project directory tree is:

D:\EclipseWorkspace-GIT\mongowithcomposer 
├───src
│   ├───MongoHandler
│   ├───WebContent
│   │   ├───js
│   │   ├───resources
│   │   │   └───images
│   │   ├───DEFINITIONS.PHP
│   │   ├───HOME.PHP
│   │   └───style
│   └───XML-Handler
├ COMPOSER.JSON
├ COMPOSER.LOCK
└───vendor
    ├───composer
    ├───    AUTOLOAD.PHP
    └───mongodb
        └───mongodb
            ├───.github
            │   └───ISSUE_TEMPLATE
            ├───.phpcs
            ├───.travis
            ├───docs
            │   ├───.static
            │   ├───includes
            │   ├───reference
     .......

this is the error I got:

Warning: require_once(D:\Eclipse-Workspace-GIT\.metadata\.plugins\org.eclipse.wst.server.core\tmp6\htdocs\mongowithcomposer\autoload.php): failed to open stream: No such file or directory in D:\Eclipse-Workspace-GIT\.metadata\.plugins\org.eclipse.wst.server.core\tmp6\htdocs\mongowithcomposer\definitions.php on line 10

NOTE: In the tree output the files are higlighted by being UPPERCASE

EDIT: this is the server automatic path mapping:

<Server>
    <Port name="HTTP/1.1" protocol="HTTP">8181</Port>
    <PathMapping local="/mongowithcomposer/vendor/composer" module="mongowithcomposer" remote="D:\Eclipse-Workspace-GIT\.metadata\.plugins\org.eclipse.wst.server.core\tmp6\htdocs\mongowithcomposer"/>
    <PathMapping local="/mongowithcomposer/src" module="mongowithcomposer" remote="D:\Eclipse-Workspace-GIT\.metadata\.plugins\org.eclipse.wst.server.core\tmp6\htdocs\mongowithcomposer"/>
    <PathMapping local="/mongowithcomposer/vendor/mongodb/mongodb/src" module="mongowithcomposer" remote="D:\Eclipse-Workspace-GIT\.metadata\.plugins\org.eclipse.wst.server.core\tmp6\htdocs\mongowithcomposer"/>
</Server>

Solution

This is PDT bug. In current implementation rather than just run php -S it copy .buildpath dirs into separate dir, and then run server.

I have a plan to fix this for in Eclipse 2020-09 and already prepared issue for this: https://github.com/eclipse/pdt/issues/68



Answered By - zulus

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.