Wordpress Projects and Development Resources

Description

The IDRC produces, runs, and maintains a number of Wordpress sites.

This section of the wiki documents the various projects and resources for Wordpress development.

Current Wordpress Websites

Wordpress Dev with Windows Subsystem for Linux

Before starting, make sure Valet has not been installed previously on Windows. Uninstall that version before attempting to install Valet for Linux. See "Uninstalling Valet for Windows" below.

  1. Follow the guide: Windows Subsystem for Linux Installation Guide for Windows 10
    1. Note: The choice of Linux distribution is up to you. For these instructions, we are using Ubuntu 18.04LTS
  2. Install PHP: `sudo apt install php`
  3. Install Composer
    1. Note:
      1. There are requirements before installing Composer for Linux. See this page for the list of dependencies
      2. Most of the php dependencies can be satisfied by running `sudo apt install php-[module-name]`.
      3. php-mcrypt may require additional steps to install (see Installing php-mcrypt).
  4. Install Laravel Valet for Windows Subsystem Linux
  5. Check configuration
    1. Assuming Valet and Acrylic have been set up from step 4, you should be able to run `ping foo.test` (or any *.test domain) and get a result.
  6. Install wp-cli
    1. Install the wp cli auto-completion too
  7. Configure mysql for system user if not already done in step 3. See https://github.com/valeryan/valet-wsl/wiki/Installation-Guide#mysql
  8. Install wp-cli-valet-command
  9. build a WP site
    1. try `wp valet new <project name> --dbuser=<system username>` to build a new site.
      1. Replace '<project name>' with a name for your project. A new directory will be created with this name and will contain Wordpress.
      2. Replace '<system username>' with your Linux system username.
    2. It is possible that going to https://<project name>.test may give a 404 error. You may have to manually link using Valet from within the Wordpress project directory. i.e. `valet link`.

After Installing WP with WSL

Using Windows for development, and Wordpress on Ubuntu

Ubuntu on WSL lacks a rich IDE aside from terminal based text editors (vi, emacs, etc.). To use Windows for development, and use Ubuntu for Wordpress hosting try the following:

  • Checkout your code project to a directory on Windows. (i.e. c:\development\my-project-plugin)
  • In Ubuntu, make a symbolic link to your project on Windows. Example:

    ln -s /mnt/c/development/my-project-plugin/ ~/wordpress/wp-content/plugins/my-project-plugin
  • Now you can use your Windows IDE to code, and Ubuntu for Wordpress.

Restarting Wordpress after Shutting down Ubuntu

After shutting down Ubuntu, you may need to restart Wordpress the next time logging in. Note: some of this may not be required if it is scripted / automated.

  1. Launch Ubuntu
  2. Start mysql. i.e. `sudo service mysql start`
  3. Start Valet. i.e. `valet install`
  4. From your Wordpress directory, link to Valet. i.e. `valet link`

Other Useful Packages to Install

Wordpress Dev for Windows 10 Natively

  1. Install Laravel Valet for Windows - follow the instructions in the project's Readme (i.e. install PHP, Composer, etc.)
    1. Note: you may need to configure the Acrylic DNS proxy for your network. Instructions on the Laravel Valet for Windows readme.
    2. Once you have run `valet install`, and rebooted, run `ping foo.test` to confirm valet is working.
  2. Install wp cli
    1. Create a directory where wp-cli will live (i.e. c:\wp-cli\ or c:\program files\wp-cli, etc.)
    2. From the new wp-cli directory, using Powershell execute: wget -O wp-cli.phar https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
    3. In the same directory, create a batch file called `wp.bat`. The batch file should contain:

      @ECHO OFF
      php "C:\Program Files (x86)\wp-cli\wp-cli.phar" %*
    4. The path to this new directory needs to be added to Windows 10 environment variable so the wp cli can be used. To do this:

      1. Go to Windows menu > Settings > type "environment" into the search bar > choose "Edit System Environment Variables"

      2. In the dialog that appears, choose "Environment Variables" button (bottom right)

      3. Under the "System variables" pane, choose "Path" from the list and select Edit button.

      4. Select "Browse" button and find the directory for wp-cli created earlier and OK to confirm.

      5. Logout of Windows 10 or restart

      6. Open a command prompt and type `wp`. You should see the following output:

        NAME
          wp
        
        DESCRIPTION
          Manage WordPress through the command-line.
        
        SYNOPSIS
          wp <command>
        
        SUBCOMMANDS
          cache    Adds, removes, fetches, and flushes the WP Object Cache object.
        ...

Uninstalling Valet for Windows

If Valet for Windows is installed, it may interfere with installation of Valet for Linux. To uninstall Valet for Windows:

  1. Locate Composer in the Windows file system. This may be located in a directory `c:\Users\Username\AppData\Roaming\Composer`.
  2. Open a Powershell prompt as Administrator.
  3. Change to the directory of Composer (i.e. `cd \Users\Username\AppData\Roaming\Composer`)
  4. Run `valet uninstall` to stop the valet service
  5. Run `composer global remove cretueusebiu/valet-windows`
    1. If the process stops stating nginx error.log is locked by Windows, try restarting and trying step 5 again.
    2. If after restarting uninstall still reports error.log is locked, you may have to manually terminate nginx.exe using the Task Manager.

Wordpress Development Resources