Functions and Methods where are they?

Functions and Methods where are they?

by Linda Russell -
Number of replies: 8

I am new to Moodle  Development. Whilst I can work out what functions  are doing I cannot find where some of the first ones used are defined, e.g  my_site(), instance(). I can find others. Any help greatly appreciated please. Falling at the first hurdle! Many Thanks

Average of ratings: -
In reply to Linda Russell

Re: Functions and Methods where are they?

by Michael Aherne -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Linda, are you using some kind of IDE to look at the code? If not, you should, as it's much easier to navigate through. We use Eclipse, for example, which allows you to press F3 in a function name and be taken to the function definition. Other IDEs that have this kind of functionality are Netbeans and PHP Storm. PHP Storm has a cost associated with it but the other two are free.

Average of ratings: Useful (2)
In reply to Michael Aherne

Re: Functions and Methods where are they?

by Linda Russell -

Thanks for this help. I have been using Sublime to browse and search without success.  Will install an IDE! Many thanks for your help.

Average of ratings: Useful (1)
In reply to Linda Russell

Re: Functions and Methods where are they?

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

This is something any reasonable IDE should be able to handle for you.

I use PHPStorm, which allows you to hold Ctrl and click on the name of the function, to be taken directly to the function definition.

I assume that Eclipse, Netbeans and other IDEs have similar functionality.


Average of ratings: Useful (1)
In reply to Davo Smith

Re: Functions and Methods where are they?

by Linda Russell -

Thanks for this help. I have been using Sublime to browse and search without success.  Will install an IDE! Many thanks for your help.


In reply to Davo Smith

Re: Functions and Methods where are they?

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Netbeans has a similar feature. In theory PHPStorm has better debugging (certainly than Netbeans), but I have never been able to get it to work.

In reply to Marcus Green

Re: Functions and Methods where are they?

by Linda Russell -

I have installed eclipse and it works very well. All you do is hover over the function, the script explaining what the function does appears (very useful) and then if you hold down shift the function underlines and you can click it and go to where the function is defined. Made the task of understanding Moodle much easier. So grateful for the advice.

Average of ratings: Useful (1)
In reply to Linda Russell

Re: Functions and Methods where are they?

by Yousuf Tafhim -
Using an IDE (PHPStorm, NetBeans etc.) is preferred.
However, you can do the same with using Sublime Text as well. You will need to install Package Control and then install SublimeCodeIntel.
After save the Moodle folder as a project. No whenever you will open the file and hover over any function/method you will see its definition and usage.
You can also use Moodle project on Github. Just go there and search the function/method and it will show all the matched in the repository.
Average of ratings: Useful (1)
In reply to Yousuf Tafhim

Re: Functions and Methods where are they?

by Linda Russell -

Thanks for this I will give it a go , though very impressed with Eclipse.