wp-stack

Archived PHP
On branch current
Latest: ???/cur
Running: 79d751a
??? commits behind

Starting point for WordPress theme and/or plugin development.

Prerequisites

Required Installs

Note: You could use these tools from inside the virtual machine (if you use one), but I find it easier to install and use these directly on my computer.

Optional Installs

Note: If you don't install Vagrant, you'll need to host your development code in another way.

First-time Setup

  • Download this repo (git clone https://github.com/0x0049/wp-stack project-name)
  • Move into the folder (cd project-name)

Shared Steps (with or without Vagrant)

  • Edit the URLs (and database details if needed) in config/.env.example
  • Rename or delete the theme and/or plugin folders
  • Edit the theme's style.css if creating a theme
  • Edit the plugin's plugin.php if creating a plugin
  • Edit the config variables in package.json or remove them and the deploy scripts if you won't be using them
  • Update the plugin and/or theme folder in the ITEMS object in gulpfile.js
  • If you are doing only theme or only plugin development, remove the plugin or theme line from the ITEMS object in gulpfile.js
  • Edit the WPStack JavaScript object names in wp_stack.php, plugin.php, frontend.js (both theme and plugin), and backend.js (both theme and plugin)

With Vagrant

  • If you have a .sql file in a folder called sqldump it will be automatically imported
  • Edit the host and alias names in Vagrantfile (and the IP address if you want)
  • Add host (I always add both the www and non-www versions) and IP to /etc/hosts (C:\Windows\System32\Drivers\etc\hosts on Windows)
  • Run vagrant up in the root directory of the project

Without Vagrant

  • Come up with a way to host your development code locally
  • Copy config/.env.example to config/.env
  • Add WordPress keys and salts to config/.env
  • Run composer install
  • Run npm install

Developing

  • Run vagrant up in the project root (if you installed Vagrant)
  • Run npm run gulp watch
  • Visit wp-stack.dev (or the URL you chose) in your browser
  • Develop your theme and/or plugin
  • Use wp-stack.dev:1080 to view email that WordPress sends

Deployment

  • Run npm run gulp
  • Deploy code to server (or deploy first then run npm run gulp on the server)
    • If you're on Linux, after building you can run npm run deploy which will do a git pull on the server then copy the locally built assets to the server
      • You can edit the config variables in package.json or override them locally. For example: npm config set wp-stack:server wp-stack.dev
  • Do this once: copy and edit config/.env with the details for production (or whatever environment it is)
    • Note: Ideally, you shouldn't use phpdotenv in production - actual environment variables should be set
  • Also once: if you use an environment other than "development" or "production", you'll need to add a new file under environments