Jump to content

Using DDEV for local ProcessWire development (tips & tricks)


bernhard

Recommended Posts

I've created a custom alias:

Quote

alias ddc="limactl start && ddev config --php-version=8.3 --database=mariadb:10.6 --webserver-type=apache-fpm --timezone=Europe/Vienna --omit-containers=dba --web-environment='TRACY_LOCALROOTPATH=\$DDEV_APPROOT/'"

So all I have to do is type "ddc" and hit enter

  • Like 3
Link to comment
Share on other sites

On 8/13/2024 at 4:17 PM, bernhard said:

I've created a custom alias:

So all I have to do is type "ddc" and hit enter

Have you found a solution for specifying multiple "upload_dirs" inside this initial config call? It seems not to work here.

Link to comment
Share on other sites

Here you go:

alias ddc="limactl start && ddev config --php-version=8.3 --database=mariadb:10.6 --webserver-type=apache-fpm --timezone=Europe/Vienna --omit-containers=dba --web-environment='TRACY_LOCALROOTPATH=\$DDEV_APPROOT/' --upload-dirs='site/assets/files,foo/bar'"

Note that you need to reload your shell after updating your alias file!

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

  • 2 weeks later...

I'm really enjoying DDEV and ProcessWire as I dive back into web development more seriously after many years. However, debugging has always been one of my weak areas, and I'm keen to get that sorted out.

So far, I've struggled to find a great tutorial on setting up DDEV with VS Code specifically for ProcessWire. Most of what I've come across are lengthy Drupal tutorials with Drupal-specific settings, which end up overwhelming me.

If there isn't a good resource out there, could you please share your setup procedure and the VS Code extensions, settings you've made in "settings.json" that you use with your DDEV ProcessWire environment? 

For example, I'd like to be able to open a file with a reported error from Tracy Debugger in VS Code, by clicking on it but of course:

but my current setup isn't allowing me to do that.

I'm also using RockFrontend—thank you @bernhard It's a pleasure to work with, especially when adapting static HTML templates. 

Thank you so much. 

  • Like 1
Link to comment
Share on other sites

I've done a video about DDEV, but it doesn't go through setting up ddev. Just follow the instructions on the ddev website.

 

6 minutes ago, Greg Lumley said:

For example, I'd like to be able to open a file with a reported error from Tracy Debugger in VS Code, by clicking on it but of course:

For this you need to tell tracy debugger where the files live on your local file system. This is because PW + Tracy run inside the container and inside the container your files live in /var/www/html. So if you click on a debugging link in tracy then your OS tries to find the file /var/www/html/foo.php and obviously can't find it.

// tracy config for ddev development
$config->tracy = [
  'outputMode' => 'development',
  'guestForceDevelopmentLocal' => true,
  'forceIsLocal' => true,
  'localRootPath' => '/path/to/your/project/',
  'numLogEntries' => 100, // for RockMigrations
  'editor' => 'cursor://file/%file:%line',
];

The important part for you is the "localRootPath" setting.

  • Like 2
Link to comment
Share on other sites

  • 1 month later...

Hi all!

I am developing locally with ProcessWire and DDEV, and since some days, ddev slows down very much. When I start it, it's very, very fast, but after some "database interaction" like saving some changes on pages or creating new fields, it gets terribly slow. I mean like 20 to 30 seconds load time in the backend when opening a page.

When I do `ddev restart` it's fast again for a short period of time, but after some interaction, it again slows down.

There are no errors on the page, I am really sure that this is only an issue with ddev and not with my website project. And it's a rather small project, i.e. no big database etc.

Does anyone have any tips what I can do to resolve this problem? I currently don't have any clue what's going on and where or what I could test to find out something.

Link to comment
Share on other sites

Are you on Windows? I've had similar issues on my old windows laptop but don't know why that happened. I didn't look into it, as I had to switch to apple anyhow..

Did you make sure to turn off all other projects with ddev poweroff?

Other than that I think it would be best to ask for help at DDEV, they are very active with helping out.

Link to comment
Share on other sites

Thanks @bernhard ! Yes, I turned off everything else with `ddev poweroff` and there are no other heavy tasks running on my computer. And yes, it's a Windows laptop, and some days ago there was a huge Windows update. Perhaps that did mess up something with WSL2, Docker, etc. Running my IDE PHPStorm in the Docker container didn't work well, when I first tried it, so I am currently stuck with that Windows to Docker mutagen sync stuff (which I don't fully understand yet :-)). I will try to find out when exactly the performance drops occur.

If anyone had similar performance issues, I would be thankful for any hints.

Link to comment
Share on other sites

@nurkkaMutagen is mostly for macOS users and does not have to be enabled on WSL2. WSL2 is already the preferred environment for Windows users, but if you’re still using traditional Windows this makes a huge difference. Turning on Mutagen doesn’t make sense on Linux or WSL2.

Do you have TracyDebugger installed? Take a look if you got logging enabled. In some projects Tracy Logs and Informations take a long time to load (but 30 secs is really too long). Try to disable Tracy and if the load time is still slow. But you mentioned, that after a ddev restart it feels fast again, so Tracy (or the logs) are not the culprit.

 

  • Like 1
Link to comment
Share on other sites

Thanks @dotnetic ! When installing DDEV the first time, I tried to use it "directly" in WSL2, but that didn't work (in my case). I then switched to the windows version of DDEV with Docker Desktop, and that worked perfectly until some days ago. I was really happy with that setup and had not planned to switch that anytime soon 🤪

Until now, I also had no problems with mutagen, except for sometimes a longer startup time when doing `ddev start`. But when DDEV ran, it always was super fast ... until now.

Yes, I have TracyDebugger, but logging is turned off.

🤷‍♂️

Link to comment
Share on other sites

And this is good time to say thanks to @bernhardand others here for making me look at DDEV! For some reason I used to confuse it with Devil Box. DDEV is great! I have it working for different sites some of which are in a multi-site setup with different databases but one ProcessWire.

  • Like 1
Link to comment
Share on other sites

On 10/25/2024 at 9:29 AM, nurkka said:

I am developing locally with ProcessWire and DDEV, and since some days, ddev slows down very much.

What version of DDEV are you using? I know there is a recent update, 1.23.5. I am wondering whether this could be responsible for the slowness? I am on version 1.23.4 and have not upgraded yet (and running in WSL2 as mentioned earlier).

Link to comment
Share on other sites

On 10/31/2024 at 8:14 PM, cwsoft said:

Running latest ddev version on Windows 11 under wsl2. No slow down seen yet compared to previous versions. 

Same here, but I am no longer working so intensively on the project, as it is merely finished. Therefore I have much less page reloads now, and not the same test situation as before. But the "slow downs" are gone for now.

Link to comment
Share on other sites

Anyone got xdebug + WSL2 + DDEV + VScode working please? I have read the tut in the DDEV docs but it is not working for me.

  1. In VSCode the Xdebug session starts. On the website Xdebug doesn't kick in. 
  2. After a while, VSCode breakpoints turn transparent and hovering over them says 'invalid breakpoint' or something like that.
  3. I did attempt all the WSL-related troubleshooting in the DDEV docs, e.g. the telnet connection. Was hoping for a question here.
  4. After a while VSCode says port 9003 closed.
  5. Sometimes I see notifications from ProcessWire (e.g. headers already sent) in the debug output.
  6. I am not sure whether and how to append the port number 9003 to the ddev url. E.g. mysite.ddev.site:9003. If I do this, the website hangs (chrome website cannot be reached).

Any ideas?

Thanks!

Link to comment
Share on other sites

  • 2 weeks later...

Hi all,

I have another question, this time regarding DDEV on a Mac. After having such problems with performance on my Windows 11 laptop I am considering to switch to a Mac. I have the impression that most of you work on a Mac (?), and would hope that the overall and especially DDEV performance is better there.

Regarding my recent performance problems, I could imagine that these are related to the Mutagen file system synchronisation between the Windows file system and DDEV.

=> Has the filesystem on a Mac also to be synchronized between MacOS and DDEV, or are they using the same file system?

If the filesystems also have to be synchronized, then using WSL2 and getting PHPStorm to run within WSL2 would probably be the better option.

=> Does anyone have experience with DDEV on MacOS regarding the file system synchronisation or does anybody use PHPStorm within WSL2 and could share some insights?

Link to comment
Share on other sites

@bernhard In my case, installing DDEV within WSL2 didn't work. I then switched to the Windows version of DDEV, so now I have DDEV as a Windows program, using Mutagen ... I didn't try again to install it within WSL2, because it didn't work in the first place, and that did cost a lot of time ... and I can have all the files in my "normal" filesystem. But if using DDEV within WSL2 is the way to go on Windows, I will also try that 🙂 

Link to comment
Share on other sites

I can remember that the first time installing DDEV was also a little hard for me as well. But it only has to be done once and it has definitely payed off! Good luck 🙂 

Oh and if you have troubles reach out to ddev on their git repo. They are extremely fast and helpful!

Link to comment
Share on other sites

1 hour ago, nurkka said:

But if using DDEV within WSL2 is the way to go on Windows, I will also try that 🙂 

I'd say give it a try. It's literally 2 steps. I did this recently.  I didn't do step #3 there.

Certs, multi-sites, etc., all work.

  • Like 1
Link to comment
Share on other sites

1 hour ago, nurkka said:

and I can have all the files in my "normal" filesystem

The integration of WSL2 and file explorer is very seamless. One can copy files between them as if they were on the same system. Even terminal integration is seamless. I never used WSL 1 so I don't know if it has always been like this. 

  • Like 1
Link to comment
Share on other sites

DDEV works great on Ubuntu in WSL2 on Windows 11. Installed VS Code in Windows with an extension to work remote on Linux too. So I do all my Web dev work in Ubuntu. Ubuntu file system shows up in Windows explorer too. This makes it easy to transfer files from Ubuntu to the WWW server using Filezilla on Windows by just using the local path to Ubuntu. Copying files from Windows to Ubuntu can easily be done via cp /mnt/c/Users/user/Downloads/file.ext . too. So WSL2 in comnination with DDEV and VS Code is really fun. 

  • Like 1
Link to comment
Share on other sites

×
×
  • Create New...