views:

187

answers:

6

Is there a simple way to find the file path to where a function is defined? I currently use dreamweavers FIND in an entire directory. Would be nice to have something that doesnt require downloading the entire site tho.

Any suggestions?

+3  A: 

Personally I use an IDE like Netbeans or Eclipse PDT. In the case of Netbeans you can ctrl-click on a function and it'll take you to the definition. Sometimes there is a choice in which case it'll make you select one.

But its generally bad form to reuse a function name within your code in different files. It can lead to hard-to-find bugs because it's hard for any program to figure out exactly which one function is actually getting called since source files can be included dynamically.

cletus
+1  A: 

You can't search for something (and expect to find it) unless you have a copy of all the files it might be in.

A number of IDEs have the ability to click and go from a use of a variable or function to its definition. If not that, then a multi-file searching tool within your editor, or something from a command line (such as ack) that is a little more specialised at searching source code can help. Good naming conventions can also help a lot for consistency.

It's not the question, but why don't you have a copy of the site locally - and while you are at it, keep it in version control as well?

Alister Bulman
Sometimes I work from random computers where I dont want to download the entire site... Just looking for some time savers. Thanks for the reply.
chris
A: 

so there is no function that would do this? Something like get_class() which would output the parent class but in the case the file path on the server...

chris
How would it work? Execute a PHP function that finds a function which is in a file possibly not on your local hard drive? (No. :)) Maybe you can put the source online and index it in a small database so you can easily search across it from wherever you are.
Till
it would find the file path on the remote web server or locally depending where you run the function. Like a get_functionPath(); I guess it doesn't exist... yet.
chris
+2  A: 

Would be nice to have something that doesnt require downloading the entire site tho.

I hope this doesn't mean that you're modifying the site remotely. Have a local working copy, make the changes, test them locally, then upload the changes.

A simple combo of vim and ctags makes the "go to definition" task a piece of cake.

Anonymous
Would be mainly for dissecting cms' in my free time from temporary computers. I will have to try out vim, been hearing alot of good things about it. thanks
chris
vim is not mandatory, go for emacs if you are already familiar with it.The key app here is ctags, you can use any editor that integrates well with it.
Anonymous
A: 

I'd sure like this get_functionPath() ability and anyone that has extensively had to work on other people's code would probably find it incredibly useful. We have function_exists, if that could simply return the file the function is defined in for user defined functions it would save a TON of trouble. No, not all of us use IDEs, and yes some of us have been doing this long enough to code on the production machine. Test boxes and sandboxes are for rookies.

One trick is to purposely trigger an error in the function you are trying to locate. Can save a ton of time.

reticon
A: 

You'd need to use some kind of tool that could build an index on a remote filesystem that you could download and perform local lookup and search upon. I don't know of anything that can do this and a few moments with Google didn't turn up anything.

Maybe a good idea for an open source project? hinthint

Scott Evernden