Skip to content

Local Dev Environment

IDE/software

Unzip and copy the git and php folders to a subfolder of VSCodium called "tools" and then configure VSCodium as follows. You'll want to customize the file paths to match your system.

settings.json
{
    "git.enabled": true,
    "git.path": "H:/Portable Apps/VSCodium/tools/PortableGit/bin/git.exe",
    "terminal.integrated.profiles.windows": {
        "Git CMD": {
            "path": [
                "H:/Portable Apps/VSCodium/tools/PortableGit/git-cmd.exe"
            ]
        },
        "Git Bash": {
            "path": [
                "H:/Portable Apps/VSCodium/tools/PortableGit/bin/bash.exe"
            ]
        },
    },
    "php.validate.executablePath": "H:/Portable Apps/VSCodium/tools/php/php.exe",
    "security.workspace.trust.untrustedFiles": "open",
    "[php]": {
        "editor.defaultFormatter": "bmewburn.vscode-intelephense-client"
    },
    "editor.renderWhitespace": "all",
    "git.openRepositoryInParentFolders": "always",
    "terminal.integrated.defaultProfile.windows": "Git Bash",
    "files.exclude": {
        "**/.git": false
    },
    "intelephense.stubs": [
        "wordpress",
    ],
}

Note

The last item, ("intelephense.stubs") will likely contain a whole list of software. Just add "wordpress" at the end to get autocomplete for Wordpress functions and tooltips explaining what functions do, etc.

Tip

To avoid red underlined "function not found" errors for other WP plugins like WooCommerce or CF7, you can add your local Wordpress files to Intelliphense so that it can understand them.

"intelephense.environment.includePaths":[
    "H:/laragon/www/sgcdev"
],

LocalWP

Performance tips

Exclude the Local site folders from Windows Defender (makes a BIG difference in speed; from unusable to just slow).

C:\Users\Work\AppData\Local\Programs\LocalWP\resources
C:\Users\Work\AppData\Roaming\Local\lightning-services
C:\Users\Work\Local Sites
H:\Local Sites

Don't use the .local tld, use .abc or something else.

Make sure to set a good high memory limit for both PHP and wp-config (see wp-config.php below)

Move Local WP site to a different drive

From the WP Local forums:

  • Close Local
  • Move site folder to new location
  • Open C:\Users\AppData\Roaming\Local\sites.json in a plain text editor (Notepad, etc). This file stores, among other things, the paths of all your Local sites.
  • Edit your site’s path to match new path and save the file.
  • Start Local and test.

LocalWP environment setup script can be found here: C:\Users\Work\AppData\Roaming\Local\ssh-entry

Install LocalWP on WSL

Downloads page.

Move the downloaded .deb file to the Ubuntu filesystem, then run sudo apt install ./local-9.2.4-linux.deb to install it with dependencies.

LaraGonzo

Setup

Set up LaraGonzo for a lightweight local Wordpress development/staging environment.

Install WP CLI in Laragon. (You might have to manually move the .phar and .bat files to /bin [create the dir if it doesn't already exist.]

Enable the zip extension in the PHP settings. PHP > Extensions > zip.

Setup SSL in Laragon:

  • Activate the SSL Port on: Preferences -> Services & Ports (SSL: 443)
  • Also check Menu -> Apache (or nginx) -> SSL -> Add Laragon.crt to TrustStore
  • RESTART Laragon!

Clone production site to dev

Copy all Wordpress files from the live server to your local directory.

rclone sync sgc:/home/u159938358/domains/shepherdsglobal.org/public_html [DESTINATION] -P --fast-list --exclude "*.zip" --exclude "*.gz" --sftp-disable-hashcheck --transfers 35 --checkers 35 --check-first

Tip

Ezra did extensive performance testing of rclone to strike a balance between not overloading the Hostinger server (it has a limit of 120 processes) and fastest transfers. Using --transfers 35 --checkers 35 --check-first was by far the best option.

rclone performance testing results

Clearly the server isn't very good at multi-tasking, so it's better to get the checking out of the way first, and then transfer files. That way we optimally utilize both CPU/process and bandwidth.

Plugins folder (~19,000 files - 290.9 MB)

--transfers --checkers Processes Time Notes
40 2 114 2 checkers isn't enough
35 4 114 4m39.5s from scratch
32 6 110 4m3.1s from scratch
38 38 119 3m55.8s using --check-first (had a few "faults")
35 35 110 3m52.5s using --check-first

Entire site (~30,000 files - 1.3 GB)

--transfers --checkers Processes Time Notes
20 4 - 12m10.5s
35 35 107 8m42.5s used --check-first

Import a fresh copy of the live database:

Warning

Make sure your local dev site is "running" before you run the following command.

wp db reset --yes && ssh -C -p65002 u159938358@217.196.55.99 "wp db export - --path=/home/u159938358/domains/shepherdsglobal.org/public_html | sed 's/\\-/-/g'" | wp db import -

Tip

The reason for the sed 's/\\-/-/g' bit is because of an issue with a MariaDB compatibility update that adds a weird comment to the sql dump which triggers the error: ERROR at line 1: Unknown command '\-'.

Alternatively, you can just import a local SQL file that you downloaded from the server or restored from a backup:

mysql [DB name] -u root < H:\laragon\wordpress.sql

Edit wp-config.php to be as follows:

wp-config.php
/** The name of the database for WordPress */
define( 'DB_NAME', 'local' );

/** Database username */
define( 'DB_USER', 'root' );

/** Database password */
define( 'DB_PASSWORD', 'root' );

/** Database hostname */
define( 'DB_HOST', '127.0.0.1:10006' );

define( 'WP_HOME', 'https://sgcdev.test' );
define( 'WP_SITEURL', 'https://sgcdev.test' );

define( 'WP_MEMORY_LIMIT', '256M' );

Change the logging to:

wp-config.php
define( 'WP_DEBUG', true);
define( 'WP_DEBUG_LOG', 'wp-debug-sgc.log' );
define( 'WP_DEBUG_DISPLAY', true );
@ini_set( 'display_errors', 1 );

Post-sync actions

Finally, disable plugins that interfere with local testing:

  • FluentSMTP
  • CF Turnstile

Otherwise you'll run into errors, especially when running the automated tests.

Live sync changes in the git repo to the staging site

Use RealTimeSync (from FreeFileSync) to keep them up to date. (Currently using a FFS batch file on the Desktop)