项目作者: desaiuditd

项目描述 :
A skeleton repo as a starter for WordPress websites using Bedrock. https://roots.io/bedrock/. Local Development via Lando. https://lando.dev/
高级语言: PHP
项目地址: git://github.com/desaiuditd/wp-skeleton.git
创建时间: 2019-10-13T01:13:08Z
项目社区:https://github.com/desaiuditd/wp-skeleton

开源协议:GNU General Public License v3.0

下载


wp-skeleton

A skeleton repo as a starter for WordPress websites using Bedrock and Lando.

Project not maintained actively.

Build

Bedrock

Bedrock is a modern WordPress stack that helps you get started with the best development tools and project structure.

Much of the philosophy behind Bedrock is inspired by the Twelve-Factor App methodology including the WordPress specific version.

Features

  • Better folder structure
  • Dependency management with Composer
  • Easy WordPress configuration with environment specific files
  • Environment variables with Dotenv
  • Autoloader for mu-plugins (use regular plugins as mu-plugins)
  • Enhanced security (separated web root and secure passwords with wp-password-bcrypt

Bedrock Documentation

Bedrock documentation is available at https://roots.io/bedrock/docs/.

Lando

Lando vastly simplifies local development and DevOps so you can focus on what’s important;
delivering value to your clients and customers. And it’s free and Open Source.

Lando Documentation

Lando documentation is available at https://docs.lando.dev/.

How to use this skeleton

  1. mkdir my-wordpress-website
  2. cd my-wordpress-website
  3. wget -qO wps bit.ly/wp-skeleton && bash wps
  4. rm -rf wps

Prerequisite

MacOS

Homebrew

  1. /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Follow the instructions from here - https://docs.brew.sh/Installation

Docker

  1. brew cask install docker

Lando

  1. brew cask install lando

This will eventually install Docker as well, as a dependency, if it’s already not installed.

Follow the instructions from here - https://docs.lando.dev/basics/installation.html#macos

Enable the SSL in local.

  1. sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/.lando/certs/lndo.site.pem

Ubuntu

Docker

Install Docker Desktop (Community Edition) by following instructions from its official website https://docs.docker.com/install/linux/docker-ce/ubuntu/.

  1. # Update the package manager.
  2. sudo apt-get update
  3. # Install dependencies.
  4. sudo apt-get install \
  5. apt-transport-https \
  6. ca-certificates \
  7. curl \
  8. gnupg-agent \
  9. software-properties-common \
  10. -y
  11. # Add Docker GPG Key.
  12. curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  13. # Verify Docker GPG Key.
  14. sudo apt-key fingerprint 0EBFCD88
  15. # Add Docker repo.
  16. sudo add-apt-repository \
  17. "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
  18. $(lsb_release -cs) \
  19. stable"
  20. # Update the package manager.
  21. sudo apt-get update
  22. # Install docker
  23. sudo apt-get install docker-ce docker-ce-cli containerd.io -y

Lando

Follow the instructions from here and install Lando.

  • Download the *.deb file of the latest version from the Github releases page.
  • Run the required package installation command for your os eg sudo dpkg -i lando-stable.deb.
    • Note that you may also be able to just double click on the package and install via your distributions “Software Center” or equivalent.
  • Enable the SSL in local.
  1. sudo cp -r ~/.lando/certs/lndo.site.pem /usr/local/share/ca-certificates/lndo.site.pem
  2. sudo cp -r ~/.lando/certs/lndo.site.crt /usr/local/share/ca-certificates/lndo.site.crt
  3. sudo update-ca-certificates

Local Development

  • Create .env file for the project.
    • cp .env.example .env
    • Change these values, if needed. DB_NAME, DB_USER, DB_PASSWORD, DB_HOST, WP_HOME. (Optional, in case of default setup with Lando)
    • Generate secretes with WordPress salts generator provided by Roots.
      • AUTH_KEY, SECURE_AUTH_KEY, LOGGED_IN_KEY, NONCE_KEY, AUTH_SALT, SECURE_AUTH_SALT, LOGGED_IN_SALT, NONCE_SALT
  • Run lando start. Initial start may take some time.

Local URLs

SSH into Containers

  • WordPress App Container: lando ssh -s appserver
  • Node Container for building assets: lando ssh -s assets
  • Database Container: lando ssh -s database

Check Linting in local.

  • Lint JS/CSS/SCSS files in local: lando npm run lint
  • Lint PHP files in local (phpcs): lando ssh -s appserver -c "./vendor/bin/phpcs -p -s -v --standard=phpcs.xml --extensions=php ./web/app ./config"
  • Scan phpmd in local: lando ssh -s appserver -c "./vendor/bin/phpmd web/app,config text phpmd.xml --suffixes php"

Themes

Add theme(s) in web/app/themes/ as you would for a normal WordPress site.

Also, override the WP_DEFAULT_THEME constant to set the theme directory in config/application.php

Add below line

  1. Config::define( 'WP_DEFAULT_THEME', Config::get( 'CONTENT_DIR' ) . '/themes' );

after the custom content directory is defined.

  1. /**
  2. * Custom Content Directory
  3. */
  4. Config::define( 'CONTENT_DIR', '/app' );
  5. Config::define( 'WP_CONTENT_DIR', $webroot_dir . Config::get( 'CONTENT_DIR' ) );
  6. Config::define( 'WP_CONTENT_URL', Config::get( 'WP_HOME' ) . Config::get( 'CONTENT_DIR' ) );

Plugins

Add plugin(s) in web/app/mu-plugins/ as you would for a normal WordPress site.

Also, whitelist the plugin in .gitignore file, so that you can commit the files into the repo.

ToDO

  • husky/lint-staged and pre-commit hooks are probably not working.