Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go to definition -> no definition found #225

Open
TypedSource opened this issue Dec 7, 2017 · 43 comments
Open

Go to definition -> no definition found #225

TypedSource opened this issue Dec 7, 2017 · 43 comments

Comments

@TypedSource
Copy link

TypedSource commented Dec 7, 2017

i installed php-intellisense in the morning, disabled php.suggest.basic, set php.executablePath and opened my php project folder (inserted into workspace).

if i want to go to a definition of a class or function or var i allways get a message that no definition is available.

http://prntscr.com/hk8x14

the project was written in intelliJ and all works fine there. a change to vscode without correct working php intellisense is senseless.

@sunverwerth
Copy link

Do you see any errors under "Help" > "Developer Tools"

@TypedSource
Copy link
Author

TypedSource commented Dec 7, 2017

No, there is no error in the console and no error in the network tab. looks all fine.

nothing is triggered in the logs on trying to jump to definition

@rquispeq
Copy link

I have the same problem too, those options only work if i want a definition in the current file

@TypedSource
Copy link
Author

no sollution for it? i think vscode is going to be useless for me as php coder under windows now and i switch back to intelliJ or Atom

@pacobyte
Copy link

Go to Definition is the first feature of this extension that I tried. Instead of getting an error, the "progressbar" just keeps moving across the screen as if it's constantly trying.

Does Go to Definition work for anyone? Or is there something specifically wrong with our installations?

@iEns
Copy link

iEns commented Feb 2, 2018

I have the same problem.

  1. I can only go to a definition in the same file.
  2. If I open the file containing the definition, I can now go to the definition.
  3. If I close the file containing the definition again, I can still go to the definition.
  4. After restart of VS Code I am back to step 1.

Any way of forcing a scan or indexing of the workspace?

(I'm on MacOS 10.13.3)

[Edit] No errors listed in Developer Tools console.

@cha0s
Copy link

cha0s commented Feb 25, 2018

Same. Go to definition only works for definitions that exist in already-opened files. This makes closing and reopening a PHP project extremely painful.

@rquispeq
Copy link

Hi, I remember that i coudn't fix this problem, but then i found a extension called Codeiginiter Intelliphense or something, and it has those options too. Of course, it only works if you have the framework. It could help somebody :)

@benyaminl
Copy link

Does anyone here have try to reset the php.exe? Sometimes the php.exe isn't working and need to be killed.

@minkmk94
Copy link

I have same problem, i need this feature like "Go to definition" of Sublime text 3

@wagnerjsilva
Copy link

I definitely need to be able to go to definition as a PHP developer.
Shame, I really liked vs code, but this is an essential feature.

@torykepler
Copy link

As others have mentioned, 'Go to definition' only seems to work if you have already opened the file where the definition is located. Does anyone have a solution for this?

@benyaminl
Copy link

benyaminl commented May 22, 2018 via email

@JoffreyPoreeCoding
Copy link

Same issue here...

@tposcic
Copy link

tposcic commented May 29, 2018

Same issue here. Quite a pain in the ass

@sunverwerth
Copy link

Can anybody give more information? It works fine for me.

Extension version? Operating system? PHP Version? How many source files?

@Valera1980
Copy link

Valera1980 commented Jun 5, 2018

go to definition not working
default

win 7 sp1

@danielhuang-030
Copy link

not working for me too, my info:

  • OS: WINDOWS 10 Home
  • VS Code ver
    20180731vscodever
  • VS Code ext
    20180731activeext
  • VS Code user settings
    20180731usersettings
  • function undefined
    20180731cannotfind

@benyaminl
Copy link

@danielhuang-030 When you tried the autocomplete does the autocomplete work? If not than don't expect that the goto function would work. I suggest to try https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client I don't advertise it, but for now that's a alternative that works very good and not depends on php.exe

@danielhuang-030

This comment has been minimized.

@vasilestefirta
Copy link

vasilestefirta commented Sep 10, 2018

Any updates on this issue? I have the same problem! This is probably the most important feature everyone is looking for and there has to be a solution to solve the current problem.

VS Code - version 1.27.1
PHP IntelliSense - version 2.3.5
PHP 7.1.16
Mac OS High Sierra - version 10.13.6

---- UPDATE ----
Actually I think it works it some use-cases and it doesn't it some different use-cases. For example, I have this code from a Laravel project:

    /**
     * Show details for a given listing
     *
     * @param  \App\Area   $area
     * @param  \App\Listing   $listing
     *
     * @return \Illuminate\Http\Response
     */
    public function show(Area $area, Listing $listing)
    {
        if (! $listing->live()) {
            abort(404);
        }

        if (auth()->check()) {
            auth()->user()->viewedListing($listing);
        }

        return view('listings.show', compact('listing'));
    }

I was able to get the Go To Definition to work for the live() method, but not for viewedListing() method.

@benyaminl

This comment has been minimized.

@felixfbecker
Copy link
Owner

@benyaminl you already mentioned this before in the thread. Please keep this issue on topic.

To everyone else: If there is no update posted on this issue, there is no update. I don't have the capacity to investigate this in my free time. If anyone wants to do a PR with a fix, I am willing to invest time to review it. Given the amount of people here that posted here that they are affected by this, one would think someone here would care enough to look into it. It's just PHP code 🙂

@benyaminl
Copy link

benyaminl commented Sep 10, 2018

@felixfbecker I think it's time for you to set up patreon profile so it would be your side project that generate money ✌️ so you have more time for develop it because it generate money :v

@vasilestefirta

This comment has been minimized.

@Koekoe
Copy link

Koekoe commented Sep 14, 2018

On MacOS, when a folder is a symlink to another folder the content is not indexed, thus some definitions are not working. Could this be the problem ?

@cha0s
Copy link

cha0s commented Sep 15, 2018

The problem is that by default this extension doesn't scan all files. You have to do hax like patching the source, or making sure the first directory in your workspace is an aggregate of any other directories in your workspace (defeating the purpose of having them broken down cleanly in the first place).

The solution is to make the scan directories configurable, but I haven't written a patch for it yet.

@maslade
Copy link

maslade commented Nov 21, 2018

@cha0s This was it for me, and I'm curious how many others in this thread are in similar situations. I had two folders: a project folder (mostly text files and assets) and a library folder (PHP). "Go to Definition" only worked when the file containing the definition was already opened.

I then removed the project folder, so I only had the PHP folder, and now can navigate to those definitions even when the file is closed.

And for anyone wondering - I added the project folder back so that it was second on the list, and Intellisense still worked happily after a fresh restart. So it appears from behavior like the defect here is that the plugin only looks at the first directory in the list.

@moonbas3
Copy link

Works for me as well if the first folder in the project is the one including all the other code. Thanks for the tip.

@vushe
Copy link

vushe commented Feb 8, 2019

Works for me as well if the first folder in the project is the one including all the other code. Thanks for the tip.

Nope. Just endless scanning in my case... Find all references does not work too.

@ThomasK0lasa
Copy link

Same for me - the go to definition doesn't work in case of Joomla larg projects.

@Bashitha
Copy link

Same for me. Go to definition doesn't seem to be working specially when calling functions. I am using PHP in Visual Studio Code. OS is ubuntu. Auto complete is working fine. I installed PHP intelephense 0.8.8 extension. But still not working. Any updates on this issue?

@benyaminl
Copy link

Same for me. Go to definition doesn't seem to be working specially when calling functions. I am using PHP in Visual Studio Code. OS is ubuntu. Auto complete is working fine. I installed PHP intelephense 0.8.8 extension. But still not working. Any updates on this issue?

Hello please it's Intelisense project repository. Intelephense Project repository is on https://github.com/bmewburn/intelephense/issues

@Bashitha
Copy link

Bashitha commented Feb 19, 2019

Same for me. Go to definition doesn't seem to be working specially when calling functions. I am using PHP in Visual Studio Code. OS is ubuntu. Auto complete is working fine. I installed PHP intelephense 0.8.8 extension. But still not working. Any updates on this issue?

Hello please it's Intelisense project repository. Intelephense Project repository is on https://github.com/bmewburn/intelephense/issues

Hello @benyaminl Tried with Intellisense extension also. But not functioning the go to definition for function calls. Just showed as loading without directing to the definition location.

@benyaminl
Copy link

Same for me. Go to definition doesn't seem to be working specially when calling functions. I am using PHP in Visual Studio Code. OS is ubuntu. Auto complete is working fine. I installed PHP intelephense 0.8.8 extension. But still not working. Any updates on this issue?

Hello please it's Intelisense project repository. Intelephense Project repository is on https://github.com/bmewburn/intelephense/issues

Hello @benyaminl Tried with Intellisense extension also. But not functioning the go to definition for function calls. Just showed as loading without directing to the definition location.

If it's joomla seems there's some problem that you should know. Joomla code sometimes not follow the PSR standard and it's sequential in some way, that need special plugin for it. I also experience it with Laravel where the routing and other object not working and their code some follow the rule some not, Also Dolibarr ERP(based on PHP). You can't ask the universal tools to support code that's aren't standard. Sorry.

@ThomasK0lasa
Copy link

@benyaminl thank You for that information. :)
I am thinking about moving to PHP Storm because everything works fine in it. But I like the VSC. :(
I have same problem with Intelephense and Intelisense in case of Joomla and VSC. I am still thinking that maybe I have some missconfiguration.

@benyaminl
Copy link

@benyaminl thank You for that information. :)
I am thinking about moving to PHP Storm because everything works fine in it. But I like the VSC. :(
I have same problem with Intelephense and Intelisense in case of Joomla and VSC. I am still thinking that maybe I have some missconfiguration.

Not everything working in PHP Strom, Dolibarr isn't supported on both of editor, and only class, variable and such that's follow the PSR standard that's indexed. So for me it's normal for VS Code. PHP Strom is too heavy and not power friendly

@benyaminl
Copy link

Same for me. Go to definition doesn't seem to be working specially when calling functions. I am using PHP in Visual Studio Code. OS is ubuntu. Auto complete is working fine. I installed PHP intelephense 0.8.8 extension. But still not working. Any updates on this issue?

Hello please it's Intelisense project repository. Intelephense Project repository is on https://github.com/bmewburn/intelephense/issues

You've mentioned it three times already, whereas one time would be more than enough. Do you want to start discussing here bugs of PHP Intelliphense too? Politeness is highly appreciated.

I don't talk about intelephense bug, but many people refer it too much. I think I just refer them to it and stop talking OOT, sorry if it's seems so pushy, but it's intelisense project and not for other extension mater. That's why I remind them.

@dgloriaweb
Copy link

Hi, I use vscode with a codeigniter php project, and I'm making a simple model-controller stuff using CI as base, but the $this->post_model->get_posts(); isn't picking up the get_posts from the method. I also work on a huge project at work, where this would be essential, and it's quite frustrating, because I used to use phpstorm and it worked like charm.

@karensrapyan
Copy link

I see that in https://intelephense.com/ they are selling that option.
Open source VS Code:)

@yehudaTiram
Copy link

For me the issue was that vs code was using php v7.0.3
To fix it:
Go to ~\AppData\Roaming\Code\User\settings.json (Windows 10)
OR
Click F1 to open Command palette
search and select "Preferences: Open settings (UI)
search for "php.validate.executablePath"
Click edit in settings.json
in the json file change the path to the latest php version in your machin.

(for me it is "php.validate.executablePath": "C:/wamp64/bin/php/php7.4.0/php.exe",)

@szczemp
Copy link

szczemp commented May 9, 2023

I have similar problem. And with separate functions with the same name. Eg: myCustomFunction() in adminInclude.php file and myCustomFunction() in indexInclude.php. adminInclude.php file is included in admin.php and there I use myCustomFunction(). indexInclude.php is included in index.php and there I use myCustomFunction() too. Go To Definition shold find definions in both files, but there is only one sometimes from adminInclude.php someitmes from indexInclude.php.

@szczemp
Copy link

szczemp commented May 12, 2023

I have similar problem. And with separate functions with the same name. Eg: myCustomFunction() in adminInclude.php file and myCustomFunction() in indexInclude.php. adminInclude.php file is included in admin.php and there I use myCustomFunction(). indexInclude.php is included in index.php and there I use myCustomFunction() too. Go To Definition shold find definions in both files, but there is only one sometimes from adminInclude.php someitmes from indexInclude.php.

I think I found a solution. I installed the extension: https://marketplace.visualstudio.com/items?itemName=DEVSENSE.phptools-vscode Go To Definition works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests