Ensure the requirements are installed locally.
-
Open Local, click on the plus sign (+) in the bottom left corner.
-
Select "Create a new site".
-
Press "Continue" in the bottom right corner.
-
Expand the "Advanced options".
-
Enter a name (ie "MyApp CMS") as the site name.
-
(Optional) Update the local domain (like "cms.myapp.local").
-
(Optional) Update the location for the app (like
/Users/me/projects/myapp-cms
). -
Press "Continue" in the bottom right corner.
-
Select "Custom".
-
Select php version 8.1.X
-
Select Apache as the web server.
-
Select MySQL version 8.0.x
-
Press "Continue" in the bottom right corner.
-
Enter a Wordpress username (keep track of this).
-
Enter a Wordpress password (keep track of this).
-
Enter an email address to use with the Wordpress installation (keep track of this).
-
Press "Add Site" in the bottom right corner.
Local should create a generic site with a MySQL database.
The code will be located in the location defined in step 7 above (or the default ~/Local Sites/myapp-cms
).
The folder structure in the site folder will be like:
myapp-cms
├── app
│ └── public // Wordpress files
├── conf
└── logs
In a terminal:
-
Navigate to the
public
folder that holds the Wordpress files. -
From within the
public
folder remove thewp-content
folder and all of its content.rm -rf wp-content
-
Clone this repo into
wp-content
(replacemy_org
andmy_healess_wordpress_repo_name
).git clone git@github.com:my_org/my_healess_wordpress_repo_name.git wp-content
-
Open the VS Code workspace file (
hw.code-workspace
) located inside the cloned repo. -
Go to extensions and search for
@recommended
. -
Install recommended extensions.
Pro tip:
When installing extensions ins VS Code, you can install, then disable the extension. This makes the extension available, but disabled globally. Then, click on the "gear" next to the extension and select "Enable (Workspace)". This will make the extension enabled only in this workspace and not interfere with other projects.
-
Clone Wordpress Coding Standards (https://github.com/WordPress/WordPress-Coding-Standards/tree/main) in a location outside of the project.
-
Create an environment variable called
WCS_PATH
with the value of the path to the WordPress-Coding-Standards repo.# For Bash echo 'export WCS_PATH=/path/to/WordPress-Coding-Standards' >> ~/.bashrc # For Zsh echo 'export WCS_PATH=/path/to/WordPress-Coding-Standards' >> ~/.zshrc
-
Source the rule configuration file.
# For Bash source ~/.bashrc # For Zsh source ~/.zshrc
-
For convenience, symlink
phpcs
tousr/local/bin
sudo ln -s $WCS_PATH/vendor/squizlabs/php_codesniffer/bin/phpcs /usr/local/bin/phpcs
-
Configure
phpcs
(PHP Code Sniffer) to use the WordPress Coding Standards sniffsphpcs --config-set installed_paths $WCS_PATH
-
Set the WordPress rules to be the default global rules that
phpcs
uses.phpcs --config-set default_standard WordPress
The app is now ready for development.