113
THE ENTERPRISE WOR/D/THY/PRESS

The Enterprise Wor/d/thy/Press

Embed Size (px)

Citation preview

Page 1: The Enterprise Wor/d/thy/Press

THE ENTERPRISE WOR/D/THY/PRESS

Page 2: The Enterprise Wor/d/thy/Press

THE FAMOUS 5-MINUTE INSTALLATION

WORDPRESS

Page 3: The Enterprise Wor/d/thy/Press

BUT WHAT ABOUT MAINTENANCE?

WORDPRESS

Page 4: The Enterprise Wor/d/thy/Press

IS THE ADMIN THE BEST PLACE?

MANAGE THEMES & PLUGIN VERSIONS?

WORDPRESS

Page 5: The Enterprise Wor/d/thy/Press

CHANGES OR NEW FUNCTIONALITY

HOW DO YOU TEST OR DEVELOP?

WORDPRESS

Page 6: The Enterprise Wor/d/thy/Press

WITH MINIMAL DOWNTIME

AND WHAT ABOUT DEPLOYING?

WORDPRESS

Page 7: The Enterprise Wor/d/thy/Press

FOR THE BEST USER EXPERIENCE

IT NEEDS TO BE FAST!

WORDPRESS

Page 8: The Enterprise Wor/d/thy/Press

DEVOPS CLI FRONTEND SEARCH

Page 9: The Enterprise Wor/d/thy/Press

DEVOPS CLI FRONTEND SEARCH

Page 10: The Enterprise Wor/d/thy/Press

WE NEED FULL CONTROL OF DEV & OPS

Page 11: The Enterprise Wor/d/thy/Press

TO DEPLOY TO MULTIPLE ENVIRONMENTS

DEPENDENCY MANAGEMENT

Page 12: The Enterprise Wor/d/thy/Press

FOR CONSISTENT ENVIRONMENTS

AUTOMATION

Page 13: The Enterprise Wor/d/thy/Press

DEV DEPENDENCY MANAGEMENT

Page 14: The Enterprise Wor/d/thy/Press

GETCOMPOSER.ORG

COMPOSER

DEPENDENCY MANAGEMENT

Page 15: The Enterprise Wor/d/thy/Press

PHP PACKAGE REPOSITORY

PACKAGIST.ORG

DEPENDENCY MANAGEMENT

Page 16: The Enterprise Wor/d/thy/Press

CUSTOM PATHS DEFINITIONS

COMPOSER INSTALLERS

DEPENDENCY MANAGEMENT

Page 17: The Enterprise Wor/d/thy/Press

COMPOSER’ED’ PLUGIN & THEME MIRROR OF WORDPRESS.ORG

WPACKAGIST.ORG

DEPENDENCY MANAGEMENT

Page 18: The Enterprise Wor/d/thy/Press

NOT SUPPORTED IN WORDPRESS CORE :(

COMPOSER

DEPENDENCY MANAGEMENT

Page 19: The Enterprise Wor/d/thy/Press

GITHUB.COM/JOHNPBLOCH/WORDPRESS

BUT THERE IS A SOLUTION

DEPENDENCY MANAGEMENT

Page 20: The Enterprise Wor/d/thy/Press

DEPENDENCY MANAGEMENT

{ "name": "epwp/wordpress", "type": "project", "require": { "php": ">=7.0", "johnpbloch/wordpress": "4.6.1" }, "extra": { "wordpress-install-dir": "custom/path" } }

Page 21: The Enterprise Wor/d/thy/Press

1 . 2 . 3 MAJOR . MINOR . PATCH

BC-BREAKS . FEATURES . FIXES

SEMVER

DEPENDENCY MANAGEMENT

Page 22: The Enterprise Wor/d/thy/Press

~ 1 . 2 . 3 ^ 1 . 2 . 3

VERSIONING

DEPENDENCY MANAGEMENT

Page 23: The Enterprise Wor/d/thy/Press

ROOTS.IO/BEDROCK

BEDROCK

BEDROCK

Page 24: The Enterprise Wor/d/thy/Press

BEDROCK

├── composer.json ├── config │   ├── application.php │   └── environments │ ├── development.php │ ├── staging.php │ └── production.php ├── vendor └── web    ├── app    │ ├── mu-plugins    │ ├── plugins    │ ├── themes    │ └── uploads    ├── wp-config.php    ├── index.php    └── wp

Page 25: The Enterprise Wor/d/thy/Press

NEVER HARDCODE OR STORE VARIABLES

WP-CONFIG CHANGES

BEDROCK

Page 26: The Enterprise Wor/d/thy/Press

BEDROCK

/** * Use Dotenv to set required environment variables * and load .env file in root */ $dotenv = new Dotenv\Dotenv($root_dir); if (file_exists($root_dir . '/.env')) { $dotenv->load(); $dotenv->required( [ 'DB_NAME', 'DB_USER', 'DB_PASSWORD', 'WP_HOME', 'WP_SITEURL' ] ); }

Page 27: The Enterprise Wor/d/thy/Press

OPS AUTOMATION

Page 28: The Enterprise Wor/d/thy/Press

PROVISIONING, CONFIGURATION & DEPLOYMENT

ANSIBLE

AUTOMATION

Page 29: The Enterprise Wor/d/thy/Press

IN YAML FORM

PLAYBOOKS

AUTOMATION

Page 30: The Enterprise Wor/d/thy/Press

AUTOMATION

--- - hosts: webservers vars: http_port: 80 max_clients: 200 remote_user: root tasks: - name: ensure apache is at the latest version yum: name=httpd state=latest - name: write the apache config file template: src=/srv/httpd.j2 dest=/etc/httpd.conf notify: - restart apache - name: ensure apache is running (and enable it at boot) service: name=httpd state=started enabled=yes handlers: - name: restart apache service: name=httpd state=restarted

Page 31: The Enterprise Wor/d/thy/Press

DOCS.ANSIBLE.COM/ANSIBLE/

MODULES

AUTOMATION

Page 32: The Enterprise Wor/d/thy/Press

COMMUNITY ROLE MANAGER

ANSIBLE GALAXY

AUTOMATION

Page 33: The Enterprise Wor/d/thy/Press

AUTOMATION

- name: composer src: geerlingguy.composer version: 1.2.7

- name: ntp src: resmo.ntp version: 0.3.0

- name: logrotate src: nickhammond.logrotate version: fc3ea4

Page 34: The Enterprise Wor/d/thy/Press

FOR SENSITIVE DATA ENCRYPTION

ANSIBLE VAULT

AUTOMATION

Page 35: The Enterprise Wor/d/thy/Press

AUTOMATION

vi file_with_passwords.yml

==

ansible-vault edit file_with_password.yml

Page 36: The Enterprise Wor/d/thy/Press

.VAULT_PASS NOT UNDER VERSION CONTROL

KEEP YOUR KEY PRIVATE

AUTOMATION

Page 37: The Enterprise Wor/d/thy/Press

ANSIBLE-PLAYBOOK DEPLOY.YML -E ENV=<ENV> -E SITE=<SITE>

DEPLOY WITH CONFIDENCE

AUTOMATION

Page 38: The Enterprise Wor/d/thy/Press

ROOTS.IO/TRELLIS

TRELLIS

TRELLIS

Page 39: The Enterprise Wor/d/thy/Press

FOR LOCAL DEVELOPMENT

VAGRANT

AUTOMATION

Page 40: The Enterprise Wor/d/thy/Press

§ Nginx § MariaDB § PHP 7.0 § Composer § WP-CLI § LetsEncrypt SSL § Page caching like Varnish § Data caching in memory § Ops best practices

TRELLIS

Page 41: The Enterprise Wor/d/thy/Press

TRELLIS

epwp.com/ # → Root folder for the project ├── trellis/ # → Automation, provision, deployment └── site/ # → A Bedrock-based WordPress site └── web/ ├── app/ # → WordPress content directory └── wp/ # → WordPress core (don't touch!)

Page 42: The Enterprise Wor/d/thy/Press

DIY LET’S BOOTSTRAP THIS!

Page 43: The Enterprise Wor/d/thy/Press

TRELLIS

mkdir epwp.com

cd epwp.com

git clone https://github.com/jvandijk/epwp-trellis.git trellis

git clone https://github.com/jvandijk/epwp-site.git site

Page 44: The Enterprise Wor/d/thy/Press

DEVOPS CLI FRONTEND SEARCH

Page 45: The Enterprise Wor/d/thy/Press

FASTER ADMINISTRATION OF WORDPRESS

WP CLI

WP-CLI

Page 46: The Enterprise Wor/d/thy/Press

WP-CLI

vagrant@epwp:/srv/www/epwp.com/current$ wp cli info

PHP binary: /usr/bin/php7.0 PHP version: 7.0.11-2+deb.sury.org~xenial+2 php.ini used: /etc/php/7.0/cli/php.ini WP-CLI root dir: phar://wp-cli.phar WP-CLI packages dir: /home/vagrant/.wp-cli/packages/ WP-CLI global config: WP-CLI project config: /srv/www/epwp.com/current/wp-cli.yml WP-CLI version: 0.24.1

Page 47: The Enterprise Wor/d/thy/Press

TO EXECUTE DIRECT DATABASE QUERIES

WP DB

WP-CLI

Page 48: The Enterprise Wor/d/thy/Press

MIGRATE YOUR DATA

WP EXPORT & IMPORT

WP-CLI

Page 49: The Enterprise Wor/d/thy/Press

MODIFY CONTENT

WP SEARCH-REPLACE

WP-CLI

Page 50: The Enterprise Wor/d/thy/Press

INSTALL, CHECK-UPDATE, MULTISITE CHANGE

WP CORE

Page 51: The Enterprise Wor/d/thy/Press

INSTALL, CHECK-UPDATE, MULTISITE CHANGE

WP CORE

Page 52: The Enterprise Wor/d/thy/Press

`WP PACKAGE BROWSE` FOR MORE OSS CLI EXTENSIONS

WP CLI PACKAGES

WP-CLI

Page 53: The Enterprise Wor/d/thy/Press

GENERATE CODE ACCORDING TO BEST PRACTICES

WP SCAFFOLD

SCAFFOLDING

Page 54: The Enterprise Wor/d/thy/Press

GENERATE CODE FOR PLUGIN

WP SCAFFOLD PLUGIN <SLUG>

SCAFFOLDING

Page 55: The Enterprise Wor/d/thy/Press

GENERATE CODE FOR A CUSTOM POST TYPE

WP SCAFFOLD POST-TYPE <SLUG>

SCAFFOLDING

Page 56: The Enterprise Wor/d/thy/Press

GENERATE THE CODE FOR A TAXONOMY

WP SCAFFOLD TAXONOMY <SLUG> —POST-TYPES=<A,B>

SCAFFOLDING

Page 57: The Enterprise Wor/d/thy/Press

IMPLEMENT PLUGIN

<?php /* Plugin Name: My WP extension Plugin URI: https://www.a-wp-site.com/ Description: WordPress extension Version: 1.0.0 Author: Enrise Author URI: https://www.enrise.com */ require_once('src/Bootstrap.php');

new \Bootstrap::getInstance();

Page 58: The Enterprise Wor/d/thy/Press

IMPLEMENT PLUGIN

public static function getInstance() { if ( ! ( self::$instance instanceof self ) ) { self::$instance = new self(); }

return self::$instance; }

protected function __construct() { add_action( 'plugins_loaded', [ $this, 'doYourThing' ], 100 ); }

public function doYourThing() { // trigger your scaffolded code from here return; }

Page 59: The Enterprise Wor/d/thy/Press

LIST, SEARCH, INSTALL, ACTIVATE, UPDATE

WP PLUGIN

3RD PARTY PLUGIN

Page 60: The Enterprise Wor/d/thy/Press

LIST, SEARCH, INSTALL, ACTIVATE, UPDATE

WP PLUGIN

3RD PARTY PLUGIN

Page 61: The Enterprise Wor/d/thy/Press

TO LOCK ON A VERSION

COMPOSER REQUIRE WPACKAGIST-PLUGIN/SLUG

3RD PARTY PLUGIN

Page 62: The Enterprise Wor/d/thy/Press

ADVANCEDCUSTOMFIELDS.COM

LET’S EXTEND THAT CUSTOM POST TYPE

CUSTOM FIELDS

Page 63: The Enterprise Wor/d/thy/Press

COMPOSER REQUIRE WPACKAGIST-PLUGIN/ADVANCED-CUSTOM-FIELDS

ADVANCED CUSTOM FIELDS

CUSTOM FIELDS

Page 64: The Enterprise Wor/d/thy/Press

WILL BE STORED IN DATABASE

DESIGN CUSTOM FIELD ADDITIONS IN THE ADMIN

CUSTOM FIELDS

Page 65: The Enterprise Wor/d/thy/Press

UNFORTUNATELY NO DIRECT SCAFFOLDING

EXPORT CUSTOM FIELDS TO PHP

CUSTOM FIELDS

Page 66: The Enterprise Wor/d/thy/Press

DEVOPS CLI FRONTEND SEARCH

Page 67: The Enterprise Wor/d/thy/Press

DECOUPLED CMS

GOING HEADLESS

Page 68: The Enterprise Wor/d/thy/Press

NO MONOLITH STRATEGY

SCALING UP

Page 69: The Enterprise Wor/d/thy/Press

TRANSPILE TO SUPPORT OLDER TECHNOLOGIES

BLEEDING EDGE JAVASCRIPT & CSS

Page 70: The Enterprise Wor/d/thy/Press

START USING IT TODAY!

ECMASCRIPT 2016

Page 71: The Enterprise Wor/d/thy/Press

NPM INSTALL ESLINT —SAVE-DEV

ESLINT

Page 72: The Enterprise Wor/d/thy/Press

NPM INSTALL ESLINT-CONFIG-AIRBNB —SAVE-DEV

ESLINT-CONFIG-AIRBNB

Page 73: The Enterprise Wor/d/thy/Press

.ESLINTRC

{ "root": true, "extends": "airbnb", "globals": { "wp": true }, "parser": "babel-eslint", "rules": { "react/jsx-filename-extension": [ 1, { "extensions": [".js", ".jsx"] } ], } }

Page 74: The Enterprise Wor/d/thy/Press

TRANSPILE DOWN TO ECMASCRIPT 5

BABEL JS

Page 75: The Enterprise Wor/d/thy/Press

MODULE BUNDLER

WEBPACK

Page 76: The Enterprise Wor/d/thy/Press

COMPONENT BASED STRATEGY

src/components/blocks/Logo/├── Logo.css├── Logo.js├── package.json└── logo.svg

Page 77: The Enterprise Wor/d/thy/Press

EXTRACT-TEXT, FILE-LOADER, URL-LOADER

WEBPACK PLUGINS

Page 78: The Enterprise Wor/d/thy/Press

AUTO RELOAD ON EVERY CODE CHANGE

WEBPACK HOT MIDDLEWARE

Page 79: The Enterprise Wor/d/thy/Press

DESIGN IN MULTIPLE BROWSERS SIMULTANEOUS

BROWSER SYNC

Page 80: The Enterprise Wor/d/thy/Press

DEVELOPER EXPERIENCE

Page 81: The Enterprise Wor/d/thy/Press

COMPLETE DECOUPLE THE FRONTEND

WORDPRESS REST API

Page 82: The Enterprise Wor/d/thy/Press

COMPOSER REQUIRE WP-API/WP-API

WORDPRESS REST API

Page 83: The Enterprise Wor/d/thy/Press

USE THE POWER OF AMAZON S3

MEDIA STORAGE

Page 84: The Enterprise Wor/d/thy/Press

COMPOSER REQUIRE HUMANMADE/S3-UPLOADS

MEDIA STORAGE

Page 85: The Enterprise Wor/d/thy/Press

ARE YOU READY?

NOW LET’S START SETTING UP

Page 86: The Enterprise Wor/d/thy/Press

SERIOUSLY?

Page 87: The Enterprise Wor/d/thy/Press

LET’S NOT REINVENT THE WHEEL..

SERIOUSLY?

Page 88: The Enterprise Wor/d/thy/Press

ROOTS.IO/SAGE

SAGE

Page 89: The Enterprise Wor/d/thy/Press

§ Sass for stylesheets § ES6 for JavaScript § Webpack for compiling assets, optimizing images, and

concatenating and minifying files § BrowserSync for synchronized browser testing § Bootstrap 4 for a front-end framework § Template inheritance

SAGE

Page 90: The Enterprise Wor/d/thy/Press

TEMPLATE STRUCTURE

$ tree templates templates ├── 404.php ├── index.php ├── layouts │   └── base.php ├── page.php ├── partials │   ├── content-page.php │   ├── content-single.php │   ├── content.php │   ├── entry-meta.php │   ├── footer.php │   ├── head.php │   ├── header.php │   ├── page-header.php │   └── sidebar.php ├── single.php └── template-custom.php

Page 91: The Enterprise Wor/d/thy/Press

composer create-project roots/sage your-theme-name 9.0.0-alpha.3

Page 92: The Enterprise Wor/d/thy/Press

DEVOPS CLI FRONTEND SEARCH

Page 93: The Enterprise Wor/d/thy/Press

WE NEED SOME DATA!

SMALL INTERMEZZO

FAKE DATA

Page 94: The Enterprise Wor/d/thy/Press

GITHUB.COM/FZANINOTTO/FAKER

FAKER

FAKE DATA

Page 95: The Enterprise Wor/d/thy/Press

EXPRESSIVE FIXTURES GENERATOR

ALICE

FAKE DATA

Page 96: The Enterprise Wor/d/thy/Press

WP PACKAGE INSTALL TRENDWERK/FAKER

WP CLI FAKER

FAKE DATA

Page 97: The Enterprise Wor/d/thy/Press

FAKE DATA

Trendwerk\Faker\Post: session{41..80}: post_content: <realText(600, 4)> post_title: '<sentence()>' post_type: 'session' post_date_gmt: <(gmdate('Y-m-d H:i:s', (time() - (rand(1, 5) * 86400) + ( rand(1, 8) * 3600))))> meta: date: <(gmdate('Ymd', strtotime(@self->post_date_gmt)))> start_time: <(strtotime(@self->post_date_gmt) - (strtotime(@self-> post_date_gmt) % 3600))> # end the session an hour later end_time: <(3600 + strtotime(@self->post_date_gmt) - (strtotime(@self-> post_date_gmt) % 3600))> speakers: <(array((string)((int)$this->valueForCurrent - 40 + 10)))> terms: location: <terms('location', 1)>

Page 98: The Enterprise Wor/d/thy/Press

WP FAKER FAKE YOUR-FILE.YML

GENERATE THE DATA

FAKE DATA

Page 99: The Enterprise Wor/d/thy/Press

DISTRIBUTED FULL TEXT SEARCH ENGINE

ELASTICSEARCH

SEARCH

Page 100: The Enterprise Wor/d/thy/Press

CONSISTENCY - AVAILABILITY - PARTITION TOLERANCE

NOSQL DATABASE

SEARCH

Page 101: The Enterprise Wor/d/thy/Press

HTTP JSON API

RESTFUL INTERFACE

SEARCH

Page 102: The Enterprise Wor/d/thy/Press

SEARCH

RDBMS ELASTICSEARCH

DATABASE INDEX

TABLE TYPE

ROW DOCUMENT

Page 103: The Enterprise Wor/d/thy/Press

DEFINING YOUR STRUCTURE

MAPPING

SEARCH

Page 104: The Enterprise Wor/d/thy/Press

"your-index" : { "mappings" : { "post" : { "properties" : { "post_content" : { "type" : "string" }, "post_date" : { "type" : "date", "format" : "YYYY-MM-dd HH:mm:ss", "include_in_all" : false }, "post_title" : { "type" : "string", "store" : true, "fields" : { "raw" : { "type" : "string", "index" : "not_analyzed" }, "sortable" : { "type" : "string", "analyzer" : "ewp_lowercase" } }, ...

Page 105: The Enterprise Wor/d/thy/Press

ANALYZED VS NOT ANALYZED

SEARCH

Page 106: The Enterprise Wor/d/thy/Press

COMPOSER REQUIRE WPACKAGIST-PLUGIN/ELASTICPRESS

ELASTICPRESS

SEARCH

Page 107: The Enterprise Wor/d/thy/Press

SEARCH

define('EP_HOST', env('EP_HOST')); define('ES_SHIELD', env('ES_SHIELD'));

wp elasticpress index --setup

Page 108: The Enterprise Wor/d/thy/Press

SEAMLESS FOR WORDPRESS SEARCH

INTEGRATES WITH WP_QUERY

SEARCH

Page 109: The Enterprise Wor/d/thy/Press

SEARCH

new WP_Query( [ 'ep_integrate' => true, 'post_type' => 'post', 'posts_per_page' => 20, ] );

Page 110: The Enterprise Wor/d/thy/Press

./DEPLOY.SH PRODUCTION EPWP.COM

RUNNING IN PRODUCTION

DEPLOY

Page 111: The Enterprise Wor/d/thy/Press

§ initialize - creates the site directory structure § update - clones the Git repo onto the remote server § prepare - prepares the files in the new release path § build - builds the new release § share - symlinks shared folders to new release § finalize - finalizes the deploy by updating the symlink

ADD YOUR DEPLOY HOOKS IN DEPLOY.YML

Page 112: The Enterprise Wor/d/thy/Press

DEVOPS CLI FRONTEND SEARCH

Page 113: The Enterprise Wor/d/thy/Press