Question about editing php files

Re: Question about editing php files

by Tim Hunt -
Number of replies: 0
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Generally, it is a good idea to work on a coyp of Moodle that is different from your live site!

So, some general advice:

1. Install a copy of Moodle on your own computer to do the developement

If is not that hard to get a copy of Moodle running. Docs at https://docs.moodle.org/dev/Setting_up_development_environment - but they are not grea. Basically you need a web server, a database (Postgres or MySQL), and PHP. They you put a copy of the Moodle code inside the server's web root and follow the process to get Moodle to install itself. Looking at the various Windows links on https://docs.moodle.org/38/en/Category:Installation may also help. (Good grief! this area of documentation needs a good sort out.)

Since you say C#, I am going to assume you are stuck on Windows (like me). Otherwise, I would say use MDK, which automates a lot of it for you. The other quick way to get working site where you can do development is to grab one of the install packs from https://download.moodle.org/windows/, and work inside there. I would say that is quicker in the short term, but you will regret it later.

Anyway, it is really worth doing this, because then you can do development with a really fast feedback cycle. Just save the file in your editor, and reload the browser window. Also, as you mess around, writing code, and debugging things, you aren't going to to break anything that matters. Once you have finished, then you can copy the new code to the server. (And I would strongly recommend using a good version control system (that is, git) to manage that.

2. Set all the relevant admin settings for Development

The most important one is Debugging. Set that to 'Developer' level when doing development, and the error messages will be much more helpful than just 500!

There must be another docs page that lists the other recommended settings (e.g. Cache language strings: off, Cache JavaScript: off) but I can't find it now.


Hope those hints help you get started.