phptools-docs icon indicating copy to clipboard operation
phptools-docs copied to clipboard

Import Class does not work the first time the App is loaded

Open lexman1958 opened this issue 1 year ago • 11 comments

I am using version 1.40.14137. This is what i did:

(1) I loaded the app into vs code the first time (2) I ran the composer install as i always delete the vendor folder when i back-up. (3) In created a new script (show below) where i instantiated a class called User (4) I tried to import the class and nothing happens. (5) I reload vs code and repeat (4) above and this time it works. Please advise or fix.

Code Sample:

Import class error

lexman1958 avatar Oct 29 '23 21:10 lexman1958

Thank you. What do you mean by

delete the vendor folder when i back-up

?

jakubmisek avatar Oct 30 '23 14:10 jakubmisek

The app involved is a Codeigniter app using composer for extension and namespace management. What i do is these

(1) Intermittently I delete the "vendor" folder and then backup the app to my server ( i dont use GitHub). (2) Then i restart vs code and the app, i will get a whole list warnings as the vendor folder has not been installed. (3) When i restart vs code (update the extension) and use composer install and rebuild the app all these warnings will resolve when the extensions get activated. (4) So far everything is working fine except for this problem where the the class auto-import does not work. (5) After i restart once again vs code, then class auto-import works.

Weird as it seems, this is what is happening. I have attached the setting json file for your investigation.

Mysetting.json

lexman1958 avatar Oct 30 '23 21:10 lexman1958

I just installed the latest version and this problem is getting more aggravated. Now when i do steps (1) to (3), at step (3) the warnings are not getting resolved. Had to switch back to version 1.40.14103.

lexman1958 avatar Oct 30 '23 21:10 lexman1958

Thank you for the details. If this happens again, may I ask for the log in OUTPUT window, "PHP Language Server" tab? That would help a lot.

jakubmisek avatar Nov 01 '23 11:11 jakubmisek

@jakubmisek

I installed the pre-release version 1.40.14179. I did further diagnostic tests and this is my feedback:

(1) The Output log does not show anything. (2) The problem about not resolving warnings is no longer there. (3) The problem of importing class occurs only when i do a fresh start. See screencap below:

Import class error 2

(4) This problem does not occur when i do restart as shown in screencap below:

Import class error 3

lexman1958 avatar Nov 01 '23 22:11 lexman1958

@jakubmisek ,

After updating to the latest version (pre-release), sorry to say that the problem about not resolving warnings is exists and so also with importing of the class. Both problems have not been resolved. After rigorous testing, decided to revert to version 1.40.14103 which at least resolves the problem of resolving the issues.

lexman1958 avatar Nov 03 '23 21:11 lexman1958

Tried this extension today, and auto-import doesn't work for me, at all - it shows the auto-import suggestion when I hit CTRL+SPACE, but when I TAB or ENTER to perform the completion, nothing happens.

Latest version of VS Code, and PHP language level set to 8.0 or 8.1, if that matters.

Reverting to PHP Intelephense for now, but let me know if you think this has been fixed, I'd be happy to test the extension again. :-)

mindplay-dk avatar Dec 09 '23 13:12 mindplay-dk

@mindplay-dk @lexman1958 Thank you all for reporting the issue and for the feedback!

May I ask to send the text from VS Code's OUTPUT? (if any exception happens internally, it would be there)

  • [ ] View -> Output -> PHP Language Server image

Eventually, the very first load of a workspace may take a few seconds, and you should see the following in the status bar (bottom left):

  • [ ] Check status bar image

If there are no errors, VS Code may report something in its Console:

  • [ ] Help -> Toggle Developer Tools -> Console image

Thank you, I'm sure we'll figure this out!

jakubmisek avatar Dec 10 '23 11:12 jakubmisek

I haven't seen anything currently, but will check on it if I run into this again.

mindplay-dk avatar Dec 12 '23 13:12 mindplay-dk

@jakubmisek

Hi, Having the same issue, auto-import does not work at all and since no one else posted logs here it is.

EDIT: If that can help, for some reason it works in the directory "smr-backend" but not in any other. Reloading/Restarting VS Code does not fix the issue.

OUTPUT:

PHP Tools server started.
    PID: 128069
    Processing files: *.php; *.phtml

[Info  - 1:36:12 PM] Loaded 169 package(s) from cache in 00:00:01.8482365.
[Info  - 1:36:14 PM] Loaded 172 package(s) from cache in 00:00:01.8245763.
[Info  - 1:36:14 PM] Loaded 169 package(s) from cache in 00:00:01.3920425.
[Info  - 1:36:15 PM] Loaded 207 package(s) from cache in 00:00:04.5851493.
[Info  - 1:36:15 PM] Processing packages in /home/whs-dev/@JASMR/app-smr/smr-backend/vendor/composer/installed.json ...
[Info  - 1:36:16 PM] Processing packages in /home/whs-dev/@JASMR/laravel-automation/vendor/composer/installed.json ...
[Info  - 1:36:16 PM] Processing packages in /home/whs-dev/@JASMR/laravel-auth/vendor/composer/installed.json ...
[Info  - 1:36:16 PM] Processing packages in /home/whs-dev/@JASMR/laravel-crudmanager/vendor/composer/installed.json ...
[Info  - 1:36:16 PM] Processing done in 00:00:00.0002406.
[Info  - 1:36:16 PM] Processing done in 00:00:00.0003138.
[Info  - 1:36:16 PM] Processing done in 00:00:00.0003397.
[Info  - 1:36:16 PM] Processing done in 00:00:00.2843805.
> 1 file system change(s) ...
> 1 file system change(s) ...
> 1 file system change(s) ...

Vscode console: I cleared everything before trying auto-import but there was no other error.

image

webdo avatar Jan 22 '24 18:01 webdo

@webdo @jakubmisek

Its odd. I am using version 1.43.14770 and it seems to work fine. I just tested again a minute before this post. Previously, i did have this problem where the auto import did not work on first load of vscode but worked after a reload. But now it seems to work fine.

Will test further.

lexman1958 avatar Jan 22 '24 21:01 lexman1958