Getting started with moodle development

Getting started with moodle development

by Jason welch -
Number of replies: 17
Hello

I have been working with moodle for a few weeks now but pretty much just with the end user side and not so much on the development side. I keep going through the wiki, the forums, google, etc but moodle is really hard to figure out without knowing someone who is a pro already with it. I am just having a hard time grasping how everything interconnects. For example, the view.php file shows the a course, but how does it display the contents of the course such as displaying the quiz links, forum links, etc.

Some of the people here make it look easy... I just can't seem to figure it out and I have worked with many C++ api's with 500,000 lines plus!

Any feedback would be really appreciated. Thanks.
-Jason
Average of ratings: -
In reply to Jason welch

Re: Getting started with moodle development

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
You might consider setting up phpEclipse with the debugger as that way you can step through the code line by line. It is quite a pain to set it up but very nice once it works.
In reply to Marcus Green

Re: Getting started with moodle development

by David Horat -
I am planning to develop a "Moodle Integrated Development Environment" based on Eclipse with PHPEclipse, so it will be easier for newcomers to develop in Moodle. Hopefully it will also prevent from a few non-moodle technical problems, such as setting another utility without the correct knowledge. What does the community think? smile
In reply to David Horat

Re: Getting started with moodle development

by Ye Chen -

If this kind of Moodle Integrated Development Environment can be available soon, it will save a lot of newcomers' time to get to know how to develop in moodle. I have been exploring moodle for last few weeks. It is still piece by piece, as end users, I may already get a lot of informaiton, as a developer, I still need to put things together to understand how moodle components talk to each other. How to add new function, new page in it.

Anyway, as a new developer, I am looking forward to this kind of development tool available.

In reply to David Horat

Re: Getting started with moodle development

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
I think that a MIDE baseed on PHPEclipse is a very good idea.

The utter stinker for me was getting the debugger working. I worked on it every evening for about a week and so did one of the chaps I work with. We are both programmers for a living so some instructions would be most handy. Contact me at marcusavgreen at gmail for more dirt on what is required to make it work (or perhaps we should have that discussion here in the open)...


In reply to Marcus Green

Re: Getting started with moodle development

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Yes please tell us all.
In reply to Tim Hunt

Re: Getting started with moodle development

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
OK, when I get a moment at home I'll sit down in front of my laptop and post a description of my setup here in this thread.
In reply to Marcus Green

Re: Getting started with moodle development

by David Horat -
Cool. I hope to have the first release of the Moodle IDE this week. smile
In reply to Marcus Green

Setting up debugging Moodle with phpEclipse

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Setting up Eclipse to debug PHP

It is possible to set up Eclipse to debug PHP code in a similar way to how any other debugger works. My background is as a Java programmer and after spending about five evenings working on it I had Eclipse debugging PHP in a similar way to how Eclipse or Netbeans debugs Java or JSP pages. However it does take quite a bit of setting up and pay close attention to the versions of the software that you have running. These are instructions are for MS Windows, for gods own operating system instructions I charge by the hour smile. I will assume you know how to configure your apache to process php files. My set up uses xampplite.


First of all take a look at the contents of http://dd.cron.ru/dbg/installation.php

Note the comment at the very end about getting the right version of the dlls. Also make sure your php is loading the right version of PHP.ini (it could be accessing the one in your Windows directory and ignoring the loading of the debugger dll)

Get hold of eclipse version `3.12 with the phpEclipse plug in installed.(That's a slightly old version of Eclipse). Setup a project so it is pointing to your moodle source code. To actually debug a project take a look at

http://www.plog4u.org/index.php/Using_PHPEclipse_:_Installation_:_Installing_the_DBG_Debugger
It is important that you call your page with the correct query string, e.g. on my local version of moodle I set up a break point in index.php, launched a debug session within eclipse and then requested the home page of moodle with the following string.

http://localhost/index.php?DBGSESSID=1@localhost:10001

If anyone has a go at this and it doesn't work, post here and I'll try to help. The attached screen shot shows it really does work with Moodle code.





Attachment php_debug.png
In reply to Marcus Green

Re: Setting up debugging Moodle with phpEclipse

by Jamie Pratt -
It seems that the latest compiled version of the dbg dll for windows is only for php 5.0.2 which is apparently buggy. I tried downloading the free version of Visual C++ and compiling the debugger dll myself but just didn't manage it.

I'm not sure how serious the bugs in php 5.0.2 are for a development system but I've given up on trying to install debug functionality on my system for now.
In reply to Jamie Pratt

Re: Setting up debugging Moodle with phpEclipse

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
I am running php 5.1.2 for windows. I can make all my files available if you like. Contact me by email at marcusavgreen at gmail.com and we could set up some chat via gmails msn or whatever.
In reply to Marcus Green

Re: Setting up debugging Moodle with phpEclipse

by Jamie Pratt -
Sorry I was wrong about 5.0.2 being the latest version of php the debugger was compiled for. 5.1.2 is available from one of the sources you list above. 5.0.2 is the version of php 5 installed with the version of xampp I installed xampp 1.49. I guess if I get a later version of xampp there would be a version with php 5.1.2 or below which will work with the debugger and not be buggy.

Did you use xampp or did you install php, apache and all separately?

Let's keep this conversation here as it might help others get the phpeclipse debugger working for them. I started editing the Moodle docs page about installing eclipse but since I got frustrated and gave up I reverted my changes. Maybe I'll have another go at some point. But it does seem a lot of trouble to go to and I'm not sure going back to eclipse 3.1.2 and installing the debugger offers a big advantage over print_r and it's chums.

By the way I couldn't install the wst plug in for eclipse 3.1.2 were others able to do this? I got some errors about a remote reference url that eclipse couldn't find to do with an apache logger.
In reply to Jamie Pratt

Re: Setting up debugging Moodle with phpEclipse

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
I think my setup started with Xampp but then I may have installed the php separatly.

The thing is about phpEclipse debugging is that once it is setup it just works. And although it is possible to do huge amounts of php programming without a debugger (aka every line of production PHP code I have written). It is a very, very nice option to have, and if it costs no money and someone else has gone through the pain of setup (e.g. you and or me), then it would be a nice thing to offer to Joe Q Moodle developer.
In reply to Marcus Green

Re: Setting up debugging Moodle with phpEclipse

by Süreç Özcan -
Hi Marcus and other Moodlers,

I have been trying to set up the debugger for Eclipse but it doesn't work. Maybe you can help me?

I am using:
Eclipse SDK: 3.2.1
XAMP : 1.6.3.a which includes (php and apache)
PHP : 5.2.3
Apache : 2.2.4
DBG : 2.15.5
PHPEclipse : 1.1.9 (2006/04/24) as described in Setting_up_Eclipse_for_Moodle_development


When I start debugging a php-file I always receive a pop-up saying: An internal error occurred during: "Computing hasChildren".

Searching in the web for this problem I may have found the solution here but I don't want to make any changes yet. Maybe this is not the solution to it. There it says on the very buttom:
"if you are really using eclipse 3.2.1, PHPeclipse 1.1.8 is not suitable.
Take the latest CVS snapshot phpeclipse-1.1.9-cvs-20060920 from sourceforge."

In the above mentioned Setting_up_Eclipse_for_Moodle_development there is stated:
"In the pop-up dialog, give the remote site a name like PHPeclipse Update Site; set the URL to http://phpeclipse.sourceforge.net/update/releases/; then click OK."
If I should use the newer phpeclipse, what would I have to type in instead?

**********************************************************
Just in case here my changes in the php.ini-file:

[debugger]
extension=php_dbg-5.2.x.dll;dbg-5.2.x.dll bei linux müsste hier stehn: extension="dbg-x.x.x.so"
debugger.enabled = true;on
debugger.profiler_enabled = true;on
debugger.hosts_allow = localhost; 127.0.0.1; host0 - trage hier die hosts ein, denen es erlaubt ist eine session zu starten. Das können IPs oder DNS-Einträge sein.
debugger.hosts_deny = ALL
debugger.ports=7869;, 10000/16

[eAccelerator]
eaccelerator.enable = "0"

[Zend]
;zend_extension_ts = "C:\Program Files\xampp\php\ext\php_xdebug-2.0.0-5.2.2.dll" ;XDEBUG
;zend_extension_ts = "C:\Program Files\xampp\php\zendOptimizer\lib\ZendExtensionManager.dll"
zend_extension_manager.optimizer_ts = "C:\Program Files\xampp\php\zendOptimizer\lib\Optimizer"
zend_optimizer.enable_loader = 0
zend_optimizer.optimization_level=15
;zend_optimizer.license_path =
; Local Variables:
; tab-width: 4
; End:

in my phpinfo I get the following like it should:
This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
with DBG v2.15.5, (C) 2000,2007, by Dmitri Dmitrienko

So I think this is set up correct. Or do I need to change the port to 10000/16 instead?
***************************************************

Trying out the suggested index.php-file from you with the following settings in the configurations:
File->
Project: moodleSue
File: moodle\index.php

Environment->Remote Debug
Remote Debug & Open with DBGSession URL in internal Browser - checked
Remote Sourcepath: D:\oezcan\workspace\moodleSue\moodle

Environment->Interpreter
C:\Program Files\xampp\php\php.exe
***************************************************

Does anyone has more experience and know what to do?
Süreç
In reply to Süreç Özcan

Re: Setting up debugging Moodle with phpEclipse

by Süreç Özcan -
see also this discussion topic, please!
In reply to Süreç Özcan

Re: Setting up debugging Moodle with phpEclipse - Netbeans PHP plugin?

by Geoffrey Rowland -
Picture of Plugin developers

Anyone used, or considering using, the new Netbeans 6.0 IDE PHP plugin for PHP/Moodle development?

We mainly use GreenFoot/BlueJ/NetBeans for teaching Java, so there would be a certain logic in using the Netbeans PHP Plugin for PHP development and Moodle tinkering. Any 'words of wisdom' about PHPeclipse v Netbeans PHP gratefully accepted wink

In reply to Geoffrey Rowland

Re: Setting up debugging Moodle with phpEclipse - Netbeans PHP plugin?

by Geoffrey Rowland -
Picture of Plugin developers
...and in case it helps anyone, here is a short tutorial for setting up XAMPP with NetBeans (+PHP plugin). Hope to have a go at this myself when our teaching term finishes.
In reply to Jason welch

Re: Getting started with moodle development

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
There are different view.php's. When your browser shows a URL like http://example.com/moodle/mod/forum/view.php?..., then the server is executing the file /mod/forum/view.php in the moodle codebase. Similarly for other URLs. That is a different file form
http://example.com/moodle/course/view.php?... The stuff in the URL after the ? gets read in by calls to functions like required_param and optional_param.

If you are use to C++, the main thing you will need to learn are 1. the client/sever nature of web applications, and 2. old fashioned non-object-oriented programming.

I second the recommendation for PHPEclipse. http://docs.moodle.org/en/Eclipse