How to run and modify moodle code.

How to run and modify moodle code.

by ajit singh -
Number of replies: 8

Hi,

 I am new to Moodle and need to use moodle code to run from local machine.

Also need to make customization in site by modifying codet. But do not find some appropriate help and video for the same.

Going though YouTube video "Moodle Programming: Part 2 - Create NetBeans project and modify apache config"

But in this they are using some Putty.exe, but how to login to Putty user and password?

Why we use Putty.exe? Is any other alternative of Putty.exe. or it is mandatory to use it for coding  in Moodle.

Please help how to build code on IDE.

Thanks

Ajit

Average of ratings: -
In reply to ajit singh

Re: How to run and modify moodle code.

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
I advise you to focus on getting Moodle to run on your local machine before worrying about the IDE.


Many people use Linux, but I use a Windows machine with a package called WAMP. The W means windows and the other letters are Apache (the web server), Mysql (the database) and the P is for PHP. I used to use a very similar package called XAMPP, both do the same job. Get one of those installed, then download the Moodle source, run the install (which creates a configuration file called config.php and installs the tables). Once you have it running then you can concern yourself with development. I use and reccomend Netbeans.

Putty is a tool for accessing the command line on a remote machine, typically this is what you use when access a Linux machine. You probably don't need to worry about that.

In reply to Marcus Green

Re: How to run and modify moodle code.

by ajit singh -

Hi Marcus,

Thanks for reply, yes I need to get Moodle to run on local machine and want to run same of Netbeans. I do not know what steps to fellow, It will be helpful, how to get Moodle code and run on Netbeans on my window 8 machine.

So please provide.

1. Step to get Moodle code.

2. How to build/configure code on Netbeans.

Thanks

Ajit

In reply to ajit singh

Re: How to run and modify moodle code.

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

What has your web searches found so far?


In reply to Marcus Green

Re: How to run and modify moodle code.

by ajit singh -

Marcus,

From Netbeans ID I am able to get Moodle code. But I do not know how to configure and run from Netbeans IDE. Not get help from Google. It would be great help if you provide some step/doc/video in support how to run Moodle code from Netbeans IDE.

Thanks

Ajit

In reply to ajit singh

Re: How to run and modify moodle code.

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Generally Netbeans is for editing your code rather than running your code. Is your Moodle running locally and have you configured Netbeans to point to that code. That process is the same as you would do for using Netbeans work with any web application (e.g. Wordpress).  It is very widely documented on the web and I have no better search engine abilities than anyone else*. 


The only situation where you might be "running Moodle from Netbeans" is when you launch it with the debugger, e.g. xdebug, but I recommend you wait until you are comfortable using Netbeans to edit the PHP code before considering that as it is complex, error prone and in my view rather buggy.


(*actually I seemed to have far better search abilities than my 16-19 year old students of computing. To quote one classic exchange came up with the gem "there isn't anything on the web about css, I have looked")

Average of ratings: Useful (1)
In reply to ajit singh

Re: How to run and modify moodle code.

by Michael Milette -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Ajit,

If you are running your editor and Moodle locally, you don't need to use Putty.

The key to achieving your goal is to first setup your environment. This will involve:

  1. Installing some basic tools. Git, for example, is used to install Moodle and contribute to the Moodle plugin repository. A big part of Moodle's development documentation is actually located within its source code. I highly recommend you find yourself a nice file search tool. I don't know what I would do without a great tool like Agent Ransack for Windows. Finally, you will very likely also benefit from a file comparison tool. There are many out there. I find WinMerge for Windows works great.
  2. Setting up a local web server such as XAMPP for Windows, Linux and OS X, MAMP for Windows and OS X (haven't used this one myself) or WAMPServer for Windows. Alternatively, you can download Moodle with a pre-configured with a web server. The nice thing about these is that they just work right out of the box. The down side is that you will soon discover limitations as soon as you want to run additional instances of Moodle, add a WordPress, Drupal or Joomla site or even just add phpMyAdmin. With your own local web server, you will be able to do this by just installing each application into a separate directory.
  3. Installing phpMyAdmin for MySQL or phpPgAdmin for Postgres. Note that these tools may even come pre-installed with your web server. Although you can technically do SQL database operations from a command line, these web based tools will make working with the database much easier.
  4. Downloading and installing Moodle. Although you can download Moodle, the best way to do this is by actually using Git. It will make updating your instance of Moodle and any code you create much easier once you learn how to use it.
  5. There are some Moodle plugins and tools that can assist you with your development efforts. We can get to that when you are ready.
  6. Installing and configuring at least one text editor. Although NetBeans is used for demonstration purposes in the video you referenced, you can actually edit Moodle code using any text editor such as Notepad++ or Sublime Text. There is no perfect text editor. Each one will have its strengths and weaknesses. I overcome this by using multiple editors. My editor recommendation: Start by trying out Sublime Text. If you seem to get the hang of it, stick with it for now. It will offer you lots of room to grow with you as you gain experience and discover what you value in an editor. If you find it overwhelming, give Notepad++ a try instead. Over the years, I've gone through several text editors as my experience and needs grew. 

Before you do any of this, we need to know:

  • The operating system of your computer, Example: Windows, Linux or Apple OS X. If using Windows, please specify the version. Windows 10 with the recent anniversary update includes developer tools that were not available in previous versions of Windows. This will affect the instructions that are provided to you by the community here. As you may have noticed, some of my recommendations are focused on Windows. If you are on Linux or OS X, some of these recommendations might be different.
  • What kind of Moodle development are you planning on doing. Are you just trying to debug some existing code, contributing to Moodle core or will you be looking to create blocks. activities, filters or themes? This will help determine what tools we recommended that might be useful.
  • Are you planning on sharing back anything you develop? This will affect how you install Moodle.

Hope you find this useful.

Best regards,

Michael Milette

Average of ratings: Useful (1)
In reply to Michael Milette

Re: How to run and modify moodle code.

by Michael Milette -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Just a little follow up regarding the text editor/IDE. There is also no rule that says you can't use multiple editors.

For example, I use the Notepad++ (free) - for Windows - because I am most comfortable with it and have configured it with all the plugins I generally use. It is very stable, has tons of useful features and the lowest learning curve for beginners. The down side of Notepad++ is that its integration with XDEBUG, the PHP debugger, just doesn't work well when it comes to large PHP projects like Moodle. It also lacks Moodle code completion and enforcement of Moodle coding standards. But it does have a few really nice features that neither Sublime Text or NetBeans have yet,

I also use Sublime Text ($70 USD) - for Windows, Linux and OS X - because it is almost as fast as Notepad++ and you can actually configure it using plugins to add most of the commonly used IDE features. It does have a slightly higher learning curve than Notepad++ but, once you get use to it, it can easily replace Notepad++. Think of Notepad++ as Sublime Text's younger sibling. I haven't had a chance to try XDEBUG with Sublime Text but I would imagine it works well given its popularity with PHP developers.

I also occasionally use NetBeans IDE PHP (free) when I need to trace through PHP code. This is a pretty complete environment with a higher learning curve than Notepad++. The sheer number of features can be overwhelming when you are just starting out. The reason I only use it occasionally is because it is a resource hog on my Windows computer due to the fact that it runs in a Java virtual machine. As a result, it loads MUCH slower than Notepad++ and Sublime Text. Once loaded, it performs at about the same speed as Sublime. I mainly use it for debugging PHP code with XDEBUG. If you tend to open and close your editor frequently, try one of the other non-IDE editors and experience the difference for yourself.

I have tried other popular text editors like Atom and Visual Studio Code but they are not suitable for Moodle development as they will slow down to a crawl when you try to open some of the larger Moodle PHP library files. Adobe Brackets actually performs quite well but occasionally has some stability issues in my experience. I don't know about you but I hate loosing my work. I have not tried PHPStorm ($$) which seem to be pretty popular amongst PHP developers. I've also read some good things about phpDesigner which loads quickly as it is a native Windows IDE. Some people have complained about stability issues and poor support - however this is just stuff I've read. When choosing an editor, my first test is to always open /lib/moodlelib.php (about 340 KB). How long did it take to open? Then scroll about half way down the file, type some text and hit ENTER a few times. How long did it take? Exit without saving. If the responsiveness of your editor was slow, it will slow down your productivity and is not suitable for Moodle development. Notepad++ and Sublime Text passed this test with flying colours.

Why this focus on the text editor? Because you will probably spend more time using this than just about any other. There is nothing quite like having tools that you are comfortable using and that meet your needs.
Average of ratings: Useful (1)
In reply to ajit singh

Re: How to run and modify moodle code.

by Clarissa S -

I agree with Michael's post.

I have written quite a bit of custom code for my implementation (corporate installation) and I have a local version of my Moodle site running with XAMPP as well as Linux versions using AWS.  For both builds I am using Postgres.  I only have PuTTY to connect to my Linux builds which you may not have at all.

I code just using basic Notepad++ when I'm on my machine and  VIM when I'm on Linux and have found them sufficient.  I don't use any fancy IDE's.  I tried using Eclipse for a while and it was helpful for processes where the user hasn't logged in yet (I redesigned the login process for my specific implementation), however, anything after the user has logged in was a pain to step through code because I was running into instances where it wanted to pull cache information and it was incredibly slow.  In the end, I have fared well just scanning through code, grep'ing for functions I'm looking for (on my AWS builds), and looking through Moodle documentation.