2

I have been writing a custom joomla 4.x component. It's not working. But rather than getting people here to debug my code I want to know how to set up a proper development environment that will give me either automated tests or failing that a verbose error message on running the code.

This question is very old and was not fully answered:

How to setup a proper extension development environment?

It mentions Docker. Does this help with error logging?
What about Composer?
Can PHP-unit be used for this edition? I seem to recall there was a different preferred unit test package for joomla 3.x.

2 Answers 2

4

I've not used Docker so I can't help with that, but I have xdebug set up on my local environment in combination with PHPStorm and that is a big help in enabling me to figure out why something's not working as expected.

I can set breakpoints wherever I want in my code and when I refresh the page with xdebug running, it will pause at the first breakpoint and I can inspect all the current variables to see if they are doing what I expect. From that breakpoint I can then either step through the code one line at a time, or continue running the code so it'll stop at the next breakpoint if there are any.

1
  • Thanks, I might try that.
    – Huw Evans
    Sep 4, 2022 at 15:12
3

I use PHPStorm + Xdebug. I used to use my own LAMP stack on my Linux computer. Earlier this year I switched to a very nice docker environment docker-lamp created by Guido De Gobbis.

It's a bit difficult to setup but when you have it running, you'll have awesome functionality: http/https, mySQL/MariaDB, phpMyAdmin, mailhog (mail catcher) and different PHP versions at the same time. Normally When you close a MySQL docker container, you'll lose your database's data. This docker-lamp environment creates SQL dumps during shutdown and loads them again during the next startup.

If you want to try it, make sure that you take the 2.0.0 branch or more recent: https://github.com/degobbis/docker-lamp/tree/2.0.0-dev

4
  • Just to clarify is this a local or remote docker instance?
    – Huw Evans
    Sep 6, 2022 at 14:20
  • 1
    It's a docker instance meant to run on your local computer for web development. btw: You'll need a modern computer with enough RAM to use docker locally smoothly.
    – pe7er
    Sep 7, 2022 at 14:40
  • I have tried Docker 2 times in the last 4 years and I ended up deleting it from my local setup both times. I have a laptop with 14 cores, 32GB ram and last week for example Docker desktop (on windows 11j ran my laptop on 100% endlessly. I’ve seen a lot of people with the same problem. I did not even want to figure that out… I stayed with WAMP and FCGI mode on local environments.
    – Zollie
    Apr 6 at 3:56
  • Yeah, thats sounds like an annoying problem indeed. Maybe docker just runs better on Linux :-) Btw: These days I still use docker but I've changed my setup. Now every project has its own docker-compose.yml file with configuration.
    – pe7er
    Apr 6 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.