There is an easy way (for testing only) and I've used it while writing the scheduler.
You can upload the modified PHP files via exec.php without having to recompile everything.
A quick and dirty script will then copy these files into the correct directory.
chmod a+rx /tmp/*; mv /tmp/*.* .
But these files will be overwritten after a reboot. It's good for testing though.
After you're done and everything works fine just compile the whole image.
This method will be your best bet for testing your modifications. Once your done with all your modifications, you can use the workon.sh script to make the changes permanent to a firmware image file.
To get to where you need to upload the modified file goto
https://192.168.0.1/exec.php or whatever your m0n0wall address is to access the webgui.
Also the last time i tried the workon.sh script it didn't work out so well. I think mount worked but unmount didn't. I don't really recall. Might need to be modified a little.