loading...

re: Looking For a Simpler Way To Develop WordPress Themes Locally. VIEW POST

FULL DISCUSSION
 

What you want is definitely possible, but as with a lot of things it might take a bit of time to get it to behave in exactly the way you want.

I use a combination of Docker and a whole bunch of Bash scripts to do what I want — used to use Vagrant, but a VM like that really burned up my laptop battery.
Whenever I start a new WordPress project, I start it off with some NPM commands:

  1. npm run docker:create-image — makes a new docker image based on the apache:php7.1 image
  2. npm run docker:create-container — create a new container based on the image, name it, and open up the relevant ports (80 and 3306)
  3. npm run docker:collect — collects a whole database, plugins and themes from the existing site, using SSH, based on information in env.sh
  4. npm run docker:start — starts the docker instance
  5. npm run docker:provision — provisions the container with the collected data, again based on env.sh in the folder root.

At this point I can run npm start to fire up browser-sync, that automatically gives me an IP and opens up a port so that other machines can visit too.

I personally combine this with webpack and browser-sync for most of the front-end stuff, but I think that's more dependant on your use case. When needed I can also log into the docker instance.

I'd really recommend messing around with all this yourself for a bit, especially the Docker bit took me a while to understand.

code of conduct - report abuse