DDEV and Craft Plugin Development

October 17, 2019 1 min read

This is an update to an earlier post about working with DDEV.

One limitation was that symbolic links didn’t work with local, out-of-project file references—like when you’d have composer use a local Craft CMS plugin that's not part of the project structure:

~/projects/my-current-project <-- where I'm working
~/projects/foo-craft-plugin <-- local plugin to be symlinked
~/projects/my-current-project/plugin <-- symlink works on Mac, not DDEV container

I solved this the hard way by running a script that used fswatch to detect changes to foo-craft-plugin and rsync them into my local project tree (my-current-project/plugin).

The easy way, it turns out, is to just mount that plugin directory into the container by creating .ddev/docker-compose.mounts.yaml and mapping the local path to one in the container:

version: "3.6"
      - "$HOME/projects/foo-craft-plugin:/var/www/html/plugin"

After a quick ddev restart the volume will be mounted inside the container.

It's important to remember is that the local (Mac) filesystem doesn't know about this arrangement, so composer updates need to be initiated from inside the container.

➜ ddev ssh    
me@project:/var/www/html$ composer update

This may not be all that new, but I’m glad I finally stumbled onto it!

Matt Stein’s face

by Matt Stein

Full stack tinkerer, sporadic blogger and Craft CMS fan occasionally found on the devMode.fm podcast.

Updated 10/18/19 at 1:29pm