I need to develop a plugin and modify certain things on the platform, but I see myself with the inconvenience of not knowing how to connect it with a development environment and how to debug it to see what each variable gets out.
Does any of you have it ready? If so, how have you done it?
General developer forum
Development and testing environment
- Add xdebug to your local copy of PHP
- Configure your IDE to allow debugging (I find PHPStorm is very straightforward for this, I am told that Eclipse and other IDEs also have this functionality)
- (Optional) add xdebug helper to Google Chrome to make it easy to turn debugging on/off
- Turn on debugging with xdebug helper, turn on listening in your IDE + add a breakpoint, refresh the page in your browser.
Sorry, Richard, but I have to disagree, Xammp is not necessarily helpful in this instance. Best to try and recreate the production site as best you can, that way you are leaving much less to chance. Also, I understand that Xammp's more recent versions have a much bigger impact on Apache and PHP than they used to, if I am reading it right. As well, we cannot assume that Jesús' server is Apache, could be Mac or WinServer or even NginX.
I sometimes develop locally on xampp (have also used mampp in the past) and sometimes develop and certainly test on a variety of linux servers and databases. One of the benefits of having some old laptops lying around.
As Moodle is cross-platform, server and database independent (isn't it?) I'm not seeing the issues and I don't understand clearly what you mean by "bigger impact".
I do a lot of development on a localhost laptop (or several different computers - using github to manage the code itself when I'm moving around) But I also have a final test system which is a (very close) mirror of the live site.
That's because, while most of the developments work with no issues at all, I have previously found problems when php settings are different, or even at one time different versions of php.
Also had an issue once where a piece of code I was given worked fine on my laptop (MySQL) but not in production (Postgres) because the original author had written specific MySQL code rather than using Moodle's data api. Now, OK that's an example of poor practice (especially when sharing code with others!), but also an example of something working on a development environment and not in production.
I should say though, that (in my experience) this is very rare and I've
hardly ever had any such problems and know people who use XAMPP
frequently as a local development tool with no issues (I use LAMP ),
but I would recommend that at least final testing should be done on a
system that as closely matches the production environment as is
Potentially bigger (or at least more frequent) issues are caused by differences in the plugins installed on a dev/test system and the live production one as some plugins can cause clashes when installed together, so that a development that works fine on a clean local install breaks on production because of a clash with another plugin.
I have done much/most of my development on WAMP. However despite that I recommend developing on the same as your target machine (very commonly Linux). That way you tend to avoid permissions issues, case sensitivity issues and strange tiny differences that cannot possibly break things, yet somehow still do.
Despite being committed to cross platform and intending only to use Moodle api stuff I have introduced bugs in code that broke a plugin on the SQL Server platform in the past.