Wordpress Development Environment

Wordpress Development Environment

Composer and WP CLI

Before anything else, we need to install WP CLI and Composer globally.

Install Composer globally
1
2
3
curl -sS https://getcomposer.org/installer -o composer-setup.php
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
rm composer-setup.php

Or alternative:

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
# try sudo install composer.phar /usr/local/bin/composer
# as that should set proper permission also
# [cp vs install](https://unix.stackexchange.com/questions/104982/why-use-install-rather-than-cp-and-mkdir)

chmod +x /usr/local/bin/composer

Setup Wordpress

Dockerized install

Dockerising WP environment is another great option and this article is a great way to explore it.

Installation using WP CLI

This is the fastest way to install classic Wordpress with WP-CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
wp core download # download
wp core config --dbhost=example_com --dbname=example_com --dbuser=example_com --dbpass="example_password" --dbprefix="examplewp_" # create wp-config.php
wp db reset --yes  # not reqired to empty database
wp core install --url="https://www.example.com" --title="Example Ltd" --admin_name=example_user --admin_password=example_password --admin_email=user@example.com # install

# set basic debugging variables in wp-config.php
# clear; tail -f wp-content/debug.log -n0
#
wp config set --raw WP_DEBUG true
wp config set --raw WP_DEBUG_LOG true
wp config set --raw WP_DEBUG_DISPLAY false

You can check the installed WP version with wp core version


To read more about Composer-based WordPress setup boilerplates, read another note

Trellis is deployment tool for remote and local WordPress LEMP stack, Sage is WordPress starter theme with templating support and such

Configure HTTP server

For composer based installs the WP folder is moved to a more secure place. Therefore, we need to make a small modifications in our nginx configuration.

Specifically, we need to set different site root.

There are new directives in ISPConfig that enable us to do just that: ##merge##, ##delete## and ##subroot _folder_## but the one we are using is simply to add this line

##subroot web ##

to ISPConfig’s nginx options (for Bedrock it’s web, for WP Starter it’s public, etc).

Install with WP Starter boilerplate

I’m using a package inpsyde/wpstarter-boilerplate to speed-up procedure

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# cd to web directory

# allow proper cache folder for composer (or use composer without cache)
chattr -i .. # needed for ispconfig
mkdir ../.cache # cache folder composer is using
chown -R --reference . ../.cache # set proper permission

runuser $(stat -c %U .) -s /bin/bash
composer create-project dnaber/wpstarter-boilerplate:dev-master .
exit

mv .env.example .env

Install with Bedrock boilerplate

Bedrock has a great folder structure. Do note that Bedrock isn’t designed with shared hosting in mind.

The beginning is the same as in WP Starter, to allow the composer’s cache to work properly:

1
2
3
4
# cd to web directory
chattr -i .. # needed for ispconfig
mkdir ../.cache # cache folder composer is using
chown -R --reference . ../.cache # set proper permission

Now we can install bedrock

1
2
3
4
5
6
runuser $(stat -c %U .) -s /bin/bash
composer create-project roots/bedrock .
cp .env.example .env
exit

nano .env

Amazing addon plugins for Bedrock:

Enable plugin & theme uploads

Does bedrock/trellis disable the ability to add/install plugins via admin?

Private package repository

Wordpress Testing

Introduction - wp-browser Setting up WPBrowser on Bedrock – theAverageDev

WP Test – The Best Tests for WordPress is old project on repo poststatus/wptest: WP Test - The Best Tests For WordPress

Wordpress tweaks

Decide on .gitignore file! Template .gitignore file for WordPress projects gitignore/WordPress.gitignore at master · github/gitignore

Local Development

Uopšte nije loš - dapače - baš dobar sad!: 10up/wp-local-docker-v2: A simple Docker based development environment for WordPress.


Conclude

What is exclusive to local development?

  • I can execute PhpStorm IDE and use all it’s advanced functionality Please, try to emulate that on VSCode

  • Can edit local graphic files. This is no reason as I would never keep it online, anyway

  • I’m independent from internet for developing. This is completely obsolete now because I can’t write a line of code without internet.

Must do from now on

  1. History of files using Git. Simple git init is enough. Use gitignore not to backup shit.
  2. Backup database manually via WP-CLI on regular basis (some cronjob or something)

Why I like bedrock?

  • root not configs are not publicly accessed so I can keep documentation

What setup to use where?

  1. Use Bedrock. If a have SSH access and can change root folder of a site
  2. Use classic setup, if I won’t have real SSH access

Postoji još jedan način!

lucanos/WordPress-Remote-Installer: Remote install WordPress, Plugins and Themes - Only 1 file uploaded via FTP je najbolji! vuče pluginove i theme sa github-a

Interesting script to auto-install Wordpress: WP Quick Install, by WP Rocket in 2014 GeekPress/WP-Quick-Install: WP Quick Install is the easiest way to install WordPress.

Ustvari super način za instalaciju WP-a The Fastest WordPress Installation - WP Quick Install


Composer Using Composer in WordPress ecosystem Updating WordPress Themes & Plugins with Composer Using Composer With WordPress — Smashing Magazine Managing WordPress With Composer | Nishiki Liu

I šta je easyengine.io? by rtCamp?


Wordless is an opinionated WordPress plugin + starter theme at repowelaika/wordless often used together with Wordless Extender from welaika/wordless-extender but it seems to me that development stopped.


Dockerizer by Easypanel is the fastest way to dockerize your apps.


date 08. Jun 2020 | modified 13. Jun 2024
filename: Wordpress » Env » Setup Environment Cont