SlideShare una empresa de Scribd logo
1 de 88
Descargar para leer sin conexión
WordPress,WordPress,
the automated waythe automated way
Michaël Perrin
Full-stack developer
PHP / Symfony, React, Elasticsearch, …
and WordPress
michael_perrin
A typical WordPressA typical WordPress
set-upset-up
A typical WordPressA typical WordPress
set-upset-up
aka. the "Famous 5-minute install"
…AND MORE STEPS…AND MORE STEPS
Select the theme.
…AND MORE STEPS…AND MORE STEPS
Select the theme.
Install plugins.
…AND MORE STEPS…AND MORE STEPS
Select the theme.
Install plugins.
Configure plugins in WordPress admin interface.
…AND MORE STEPS…AND MORE STEPS
Select the theme.
Install plugins.
Configure plugins in WordPress admin interface.
Set API keys (eg. MailChimp, Google Maps, etc.)
…AND MORE STEPS…AND MORE STEPS
Select the theme.
Install plugins.
Configure plugins in WordPress admin interface.
Set API keys (eg. MailChimp, Google Maps, etc.)
Import data
…AND MORE STEPS…AND MORE STEPS
Select the theme.
Install plugins.
Configure plugins in WordPress admin interface.
Set API keys (eg. MailChimp, Google Maps, etc.)
Import data
…
…AND MORE STEPS…AND MORE STEPS
Select the theme.
Install plugins.
Configure plugins in WordPress admin interface.
Set API keys (eg. MailChimp, Google Maps, etc.)
Import data
…
Create pages for the theme templates.
WHAT ARE WE GOING TO AUTOMATE?WHAT ARE WE GOING TO AUTOMATE?
WHAT ARE WE GOING TO AUTOMATE?WHAT ARE WE GOING TO AUTOMATE?
1. Infrastructure setup.
WHAT ARE WE GOING TO AUTOMATE?WHAT ARE WE GOING TO AUTOMATE?
1. Infrastructure setup.
2. WordPress configuration.
WHAT ARE WE GOING TO AUTOMATE?WHAT ARE WE GOING TO AUTOMATE?
1. Infrastructure setup.
2. WordPress configuration.
3. WordPress data.
BENEFITS OF AUTOMATIONBENEFITS OF AUTOMATION
Why do we want to automate things?
BENEFITS OF AUTOMATIONBENEFITS OF AUTOMATION
Why do we want to automate things?
Because developers are lazy?
BENEFITS OF AUTOMATIONBENEFITS OF AUTOMATION
Why do we want to automate things?
Because developers are lazy?
Multi-environments (staging, QA, production, …)
BENEFITS OF AUTOMATIONBENEFITS OF AUTOMATION
Why do we want to automate things?
Because developers are lazy?
Multi-environments (staging, QA, production, …)
Server configuration consistency.
BENEFITS OF AUTOMATIONBENEFITS OF AUTOMATION
Why do we want to automate things?
Because developers are lazy?
Multi-environments (staging, QA, production, …)
Server configuration consistency.
Avoids « It works on my machine ¯_( )_/¯ ».
BENEFITS OF AUTOMATIONBENEFITS OF AUTOMATION
Why do we want to automate things?
Because developers are lazy?
Multi-environments (staging, QA, production, …)
Server configuration consistency.
Avoids « It works on my machine ¯_( )_/¯ ».
Easy versioning.
BENEFITS OF AUTOMATIONBENEFITS OF AUTOMATION
Why do we want to automate things?
Because developers are lazy?
Multi-environments (staging, QA, production, …)
Server configuration consistency.
Avoids « It works on my machine ¯_( )_/¯ ».
Easy versioning.
Continuous Integration and Deployment.
BENEFITS OF AUTOMATIONBENEFITS OF AUTOMATION
Why do we want to automate things?
Because developers are lazy?
Multi-environments (staging, QA, production, …)
Server configuration consistency.
Avoids « It works on my machine ¯_( )_/¯ ».
Easy versioning.
Continuous Integration and Deployment.
Streamline team work.
BENEFITS OF AUTOMATIONBENEFITS OF AUTOMATION
Why do we want to automate things?
Because developers are lazy?
Multi-environments (staging, QA, production, …)
Server configuration consistency.
Avoids « It works on my machine ¯_( )_/¯ ».
Easy versioning.
Continuous Integration and Deployment.
Streamline team work.
Faster and predictable deployments.
BENEFITS OF AUTOMATIONBENEFITS OF AUTOMATION
Why do we want to automate things?
Because developers are lazy?
Multi-environments (staging, QA, production, …)
Server configuration consistency.
Avoids « It works on my machine ¯_( )_/¯ ».
Easy versioning.
Continuous Integration and Deployment.
Streamline team work.
Faster and predictable deployments.
"Cloud-ready".
AutomatingAutomating
infrastructure setupinfrastructure setup
QUICK INTRODUCTION ON DOCKERQUICK INTRODUCTION ON DOCKER
QUICK INTRODUCTION ON DOCKERQUICK INTRODUCTION ON DOCKER
"Lightweight virtualisation".
QUICK INTRODUCTION ON DOCKERQUICK INTRODUCTION ON DOCKER
"Lightweight virtualisation".
Each service runs in a separate Docker container.
QUICK INTRODUCTION ON DOCKERQUICK INTRODUCTION ON DOCKER
"Lightweight virtualisation".
Each service runs in a separate Docker container.
Many services already have official images.
QUICK INTRODUCTION ON DOCKERQUICK INTRODUCTION ON DOCKER
"Lightweight virtualisation".
Each service runs in a separate Docker container.
Many services already have official images.
QUICK INTRODUCTION ON DOCKERQUICK INTRODUCTION ON DOCKER
"Lightweight virtualisation".
Each service runs in a separate Docker container.
Many services already have official images.
Rule of thumb: one service per container.
QUICK INTRODUCTION ON DOCKERQUICK INTRODUCTION ON DOCKER
"Lightweight virtualisation".
Each service runs in a separate Docker container.
Many services already have official images.
Rule of thumb: one service per container.
Works on Linux, Windows, MacOS.
DOCKER: BENEFITSDOCKER: BENEFITS
Very handy for local development and for servers.
Documents and versions the infrastructure of the
project.
Allows to install any version of any dependency.
Easy to update configuration for all environmnents.
Isolation of projects.
Easy to deploy.
CONTAINERS FOR WORDPRESSCONTAINERS FOR WORDPRESS
File system link
Network link
Project files
SETTING UP DOCKER CONTAINERSSETTING UP DOCKER CONTAINERS
docker-compose.yml file at the root of the project:
services:
wordpress:
image: wordpress:5.2-php7.3-fpm-alpine
# ...
database:
image: mysql:5.7
# ...
webserver:
image: nginx:1.14-alpine
# ...
wordpress:
image: wordpress:5.2-php7.3-fpm-alpine
links:
- database:mysql
volumes:
- wordpress_data:/var/www/html
restart: always
database:
image: mysql:5.7
1
2
restart: always3
volumes:4
- db_data:/var/lib/mysql5
environment:6
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}7
MYSQL_DATABASE: ${MYSQL_DATABASE}8
MYSQL_USER: ${MYSQL_USER}9
MYSQL_PASSWORD: ${MYSQL_USER_PASSWORD}10
ports:11
- 3306:330612
restart: always
database:1
image: mysql:5.72
3
volumes:4
- db_data:/var/lib/mysql5
environment:6
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}7
MYSQL_DATABASE: ${MYSQL_DATABASE}8
MYSQL_USER: ${MYSQL_USER}9
MYSQL_PASSWORD: ${MYSQL_USER_PASSWORD}10
ports:11
- 3306:330612
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_USER_PASSWORD}
database:1
image: mysql:5.72
restart: always3
volumes:4
- db_data:/var/lib/mysql5
6
7
8
9
10
ports:11
- 3306:330612
webserver:
image: nginx:1.14-alpine
links:
- wordpress
volumes:
- wordpress_data:/var/www/html
- ./docker/nginx/website.conf:/etc/nginx/conf.d/default.conf:
ports:
- ${WEBSERVER_PORT}:80
.ENV FILE.ENV FILE
MYSQL_ROOT_PASSWORD=my_root_password
MYSQL_DATABASE=wordpress
MYSQL_USER=wordpress
MYSQL_USER_PASSWORD=wordpress_pwd
WEBSERVER_PORT=8000
ENVIRONMENT VARIABLESENVIRONMENT VARIABLES
Specific to an environment. Examples:
Database parameters
Website URLs (eg. root URL of the website, API endpoint, etc.)
Email recipients
May contain sensitive data.
Can be set in:
A .env file
In CI/CD tools like Travis, TeamCity, etc.
Not commited in the project.
PROJECT STRUCTUREPROJECT STRUCTURE
LET'S RUN ITLET'S RUN IT
One command to start Docker containers:
docker-compose up -d
LET'S RUN ITLET'S RUN IT
One command to start Docker containers:
All services are up and running:
+
docker-compose up -d
ADDING SERVICES IS EASYADDING SERVICES IS EASY
Want phpMyAdmin? Update docker-compose.yml:
Access it at
services:
# ...
phpmyadmin:
image: phpmyadmin/phpmyadmin
links:
- database:db
ports:
- 8082:80
http://localhost:8082
Automate WordPressAutomate WordPress
configurationconfiguration
DITCH THE WIZARDDITCH THE WIZARD
Set the language.
Add default admin user.
Configure database parameters.
Define posts URL structure.
Choose a theme.
Install plugins.
WP-CLIWP-CLI
WP-CLI provides a command-line interface for
many actions you might perform in the
WordPress admin.
wp-cli.org
USEFUL WP-CLI COMMANDSUSEFUL WP-CLI COMMANDS
Generate a wp-config.php file with DB parameters:
Run the standard WordPress installation process:
Install and activate plugins:
wp-cli config create --dbhost=… --dbname=… <...>
wp-cli core install --url=… --title=…
wp-cli plugin install contact-form-7 --activate
wp-cli plugin install advanced-custom-fields --activate
HOW TO INSTALLHOW TO INSTALL
Requirements for running WP-CLI:
A PHP installation.
Installing it (on every environment).
Access to the WordPress directory.
HOW TO INSTALLHOW TO INSTALL
Requirements for running WP-CLI:
A PHP installation.
Installing it (on every environment).
Access to the WordPress directory.
Let's use a Docker container!
WP-CLI IN A DOCKER CONTAINERWP-CLI IN A DOCKER CONTAINER
toolbox:
image: michaelperrin/wordpress-toolbox
volumes:
- wordpress_data:/wordpress
- ./Makefile:/scripts/Makefile
depends_on:
- database
environment:
MYSQL_HOST: ${MYSQL_HOST}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_USER_PASSWORD: ${MYSQL_USER_PASSWORD}
WORDPRESS_ADMIN_EMAIL: ${WORDPRESS_ADMIN_EMAIL}
WORDPRESS_ADMIN_PASSWORD: ${WORDPRESS_ADMIN_PASSWORD}
WORDPRESS_ADMIN_USER: ${WORDPRESS_ADMIN_USERNAME}
WORDPRESS_DOMAIN_NAME: ${WORDPRESS_DOMAIN_NAME}
WORDPRESS_WEBSITE_URL: ${WORDPRESS_WEBSITE_URL}
WORDPRESS_LOCALE: en_US
WORDPRESS_WEBSITE_POST_URL_STRUCTURE: "/%year%/%monthnum%/%day%/%postname
WORDPRESS_WEBSITE_TITLE: "My beautiful website"
- PHP
- WP-CLI
- Makefile
File system link
Network link
Project files
MAKEFILEMAKEFILE
A file containing a set of scripts grouped as tasks.
Abstracts and groups commands.
The file is versioned in the project.
Run: make task_one
task_one:
# ...
task_two:
# ...
task_three: task_one task_two
# ...
MAKEFILE FOR OUR PROJECTMAKEFILE FOR OUR PROJECT
install: start configure install_plugins set_theme
start:
docker-compose up -d
stop:
docker-compose stop
configure:
# ... (several WP-CLI commands)
set_theme:
docker-compose run --rm toolbox wp-cli theme activate my-simple-t
install_plugins:
# ... (one WP-CLI command per plugin)
ONE COMMANDONE COMMAND
Create Docker containers for WordPress, MySQL and Nginx.
Initiate the WordPress database.
Configure WordPress:
Database parameters.
Default WordPress user.
Set language.
Set default URL structure.
Activate the custom `my-simple-theme` theme.
Install plugins (Contact Form 7 and WP MailChimp as examples).
make install
Automate data changesAutomate data changes
DATA MIGRATION EXAMPLESDATA MIGRATION EXAMPLES
Remove WordPress default content.
Add page and menu entries.
Configure plugins
Add a contact form (Contact Form 7)
Define MailChimp API key
…
WP-MIGRATIONS PLUGINWP-MIGRATIONS PLUGIN
WP-MIGRATIONS PLUGINWP-MIGRATIONS PLUGIN
Inspired by for PHP and SQLDoctrine Migrations
WP-MIGRATIONS PLUGINWP-MIGRATIONS PLUGIN
Inspired by for PHP and SQL
Runs user-defined migration files to describe
data changes.
Doctrine Migrations
WP-MIGRATIONS PLUGINWP-MIGRATIONS PLUGIN
Inspired by for PHP and SQL
Runs user-defined migration files to describe
data changes.
Embeds a WP-CLI command to execute migrations.
Doctrine Migrations
ANATOMY OF A MIGRATIONANATOMY OF A MIGRATION
<?php
namespace Migration;
use WPMigrationMigrationInterface;
class Migration201909221755 implements MigrationInterface
{
public function execute()
{
// ...
}
}
MIGRATION FILESMIGRATION FILES
Stored in wp-content/migrations
Only executed once.
Should be committed to version control.
Executed on deployment.
EXAMPLEEXAMPLE
public function execute() {
$pageData = [
'post_name' => 'about', // Permalink
'post_title' => 'About us',
'post_content' => '',
'post_status' => 'publish',
'post_author' => 1,
'post_type' => 'page',
'menu_order' => 1,
];
$postId = wp_insert_post($pageData);
$this->addToMenu($postId, 'Contact');
}
class Migration201909221755 implements MigrationInterface {1
use MigrationUtilitiesTrait;2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
}19
EXAMPLE 2EXAMPLE 2
class Migration201905311454 implements MigrationInterface {
public function execute() {
$this->setMailChimpApiKey(getenv('MAILCHIMP_API_KEY'));
}
private function setMailChimpApiKey(string $key) {
$options = get_option('mc4wp');
$options['api_key'] = $key;
update_option('mc4wp', $options);
}
}
RUN THE MIGRATIONSRUN THE MIGRATIONS
make wordpress_migrations_execute
RUN THE MIGRATIONS, AGAINRUN THE MIGRATIONS, AGAIN
make wordpress_migrations_execute
BENEFITS OF MIGRATIONSBENEFITS OF MIGRATIONS
Structural changes are versioned.
Facilitate team work and easy to deploy.
No "in-between" state
Multi-environments (using environment variables)
FINAL TREE STRUCTUREFINAL TREE STRUCTURE
Only what our project needs.
Easy versioning.
Includes infrastructure & all
automations.
THANK YOU!THANK YOU!
Twitter:
Demo repository:
Slides (soon):
@michael_perrin
https://github.com/michaelperrin/automated-
wordpress-demo
http://blog.michaelperrin.fr/

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Docker and Puppet for Continuous Integration
Docker and Puppet for Continuous IntegrationDocker and Puppet for Continuous Integration
Docker and Puppet for Continuous Integration
 
yapi.js introduction (mopcon 2016 version)
yapi.js introduction (mopcon 2016 version)yapi.js introduction (mopcon 2016 version)
yapi.js introduction (mopcon 2016 version)
 
Vagrant
VagrantVagrant
Vagrant
 
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
 
Introduce native html5 streaming player
Introduce native html5 streaming playerIntroduce native html5 streaming player
Introduce native html5 streaming player
 
Composable and streamable Play apps
Composable and streamable Play appsComposable and streamable Play apps
Composable and streamable Play apps
 
EC2 AMI Factory with Chef, Berkshelf, and Packer
EC2 AMI Factory with Chef, Berkshelf, and PackerEC2 AMI Factory with Chef, Berkshelf, and Packer
EC2 AMI Factory with Chef, Berkshelf, and Packer
 
Learn you some Ansible for great good!
Learn you some Ansible for great good!Learn you some Ansible for great good!
Learn you some Ansible for great good!
 
Yapi.js, An Adaptive Streaming Web Player
Yapi.js, An Adaptive Streaming Web PlayerYapi.js, An Adaptive Streaming Web Player
Yapi.js, An Adaptive Streaming Web Player
 
Java and windows azure cloud service
Java and windows azure cloud serviceJava and windows azure cloud service
Java and windows azure cloud service
 
Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)
 
Dockerize node.js application
Dockerize node.js applicationDockerize node.js application
Dockerize node.js application
 
Docker tutorial
Docker tutorialDocker tutorial
Docker tutorial
 
DevOps, A brief introduction to Vagrant & Ansible
DevOps, A brief introduction to Vagrant & AnsibleDevOps, A brief introduction to Vagrant & Ansible
DevOps, A brief introduction to Vagrant & Ansible
 
Multi-provider Vagrant and Chef: AWS, VMware, and more
Multi-provider Vagrant and Chef: AWS, VMware, and moreMulti-provider Vagrant and Chef: AWS, VMware, and more
Multi-provider Vagrant and Chef: AWS, VMware, and more
 
Ansible - A 'crowd' introduction
Ansible - A 'crowd' introductionAnsible - A 'crowd' introduction
Ansible - A 'crowd' introduction
 
Packer
Packer Packer
Packer
 
Opscode Webinar: Cooking with Chef on Microsoft Windows
Opscode Webinar: Cooking with Chef on Microsoft WindowsOpscode Webinar: Cooking with Chef on Microsoft Windows
Opscode Webinar: Cooking with Chef on Microsoft Windows
 
Baking docker using chef
Baking docker using chefBaking docker using chef
Baking docker using chef
 
Docker Containers: Developer’s experience and building robust developer envir...
Docker Containers: Developer’s experience and building robust developer envir...Docker Containers: Developer’s experience and building robust developer envir...
Docker Containers: Developer’s experience and building robust developer envir...
 

Similar a Word press, the automated way

Developing and Deploying PHP with Docker
Developing and Deploying PHP with DockerDeveloping and Deploying PHP with Docker
Developing and Deploying PHP with Docker
Patrick Mizer
 
Virtualize and automate your development environment for fun and profit
Virtualize and automate your development environment for fun and profitVirtualize and automate your development environment for fun and profit
Virtualize and automate your development environment for fun and profit
Andreas Heim
 

Similar a Word press, the automated way (20)

Developing and Deploying PHP with Docker
Developing and Deploying PHP with DockerDeveloping and Deploying PHP with Docker
Developing and Deploying PHP with Docker
 
Virtualization and Cloud Computing with Elastic Server On Demand
Virtualization and Cloud Computing with Elastic Server On DemandVirtualization and Cloud Computing with Elastic Server On Demand
Virtualization and Cloud Computing with Elastic Server On Demand
 
Improve your Java Environment with Docker
Improve your Java Environment with DockerImprove your Java Environment with Docker
Improve your Java Environment with Docker
 
Demystifying Docker101
Demystifying Docker101Demystifying Docker101
Demystifying Docker101
 
Demystifying Docker
Demystifying DockerDemystifying Docker
Demystifying Docker
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
 
Better Operations into the Cloud
Better Operations  into the CloudBetter Operations  into the Cloud
Better Operations into the Cloud
 
Omaha (Google Update) server
Omaha (Google Update) serverOmaha (Google Update) server
Omaha (Google Update) server
 
Virtualize and automate your development environment for fun and profit
Virtualize and automate your development environment for fun and profitVirtualize and automate your development environment for fun and profit
Virtualize and automate your development environment for fun and profit
 
Automating That "Other" OS
Automating That "Other" OSAutomating That "Other" OS
Automating That "Other" OS
 
Docker 101
Docker 101 Docker 101
Docker 101
 
2016 - Easing Your Way Into Docker: Lessons From a Journey to Production
2016 - Easing Your Way Into Docker: Lessons From a Journey to Production2016 - Easing Your Way Into Docker: Lessons From a Journey to Production
2016 - Easing Your Way Into Docker: Lessons From a Journey to Production
 
Experts Live Europe 2017 - Why you should care about Docker - an introduction
Experts Live Europe 2017 - Why you should care about Docker - an introductionExperts Live Europe 2017 - Why you should care about Docker - an introduction
Experts Live Europe 2017 - Why you should care about Docker - an introduction
 
DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slides
 
Docker for developers on mac and windows
Docker for developers on mac and windowsDocker for developers on mac and windows
Docker for developers on mac and windows
 
Continuous Integration & Development with Gitlab
Continuous Integration & Development with GitlabContinuous Integration & Development with Gitlab
Continuous Integration & Development with Gitlab
 
Deploy Angular to the Cloud (ngBucharest)
Deploy Angular to the Cloud (ngBucharest)Deploy Angular to the Cloud (ngBucharest)
Deploy Angular to the Cloud (ngBucharest)
 
Introduction Into Docker Ecosystem
Introduction Into Docker EcosystemIntroduction Into Docker Ecosystem
Introduction Into Docker Ecosystem
 
How to create your own hack environment
How to create your own hack environmentHow to create your own hack environment
How to create your own hack environment
 

Último

VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Chandigarh Call girls 9053900678 Call girls in Chandigarh
 
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
@Chandigarh #call #Girls 9053900678 @Call #Girls in @Punjab 9053900678
 
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Último (20)

Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
 
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
 
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
 
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
 
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
 
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
 
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
 
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceBusty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
 
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
 
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
 
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirt
 
Al Barsha Night Partner +0567686026 Call Girls Dubai
Al Barsha Night Partner +0567686026 Call Girls  DubaiAl Barsha Night Partner +0567686026 Call Girls  Dubai
Al Barsha Night Partner +0567686026 Call Girls Dubai
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirt
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
 
Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
 
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
 

Word press, the automated way

  • 2. Michaël Perrin Full-stack developer PHP / Symfony, React, Elasticsearch, … and WordPress michael_perrin
  • 3. A typical WordPressA typical WordPress set-upset-up
  • 4. A typical WordPressA typical WordPress set-upset-up aka. the "Famous 5-minute install"
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14. …AND MORE STEPS…AND MORE STEPS Select the theme.
  • 15. …AND MORE STEPS…AND MORE STEPS Select the theme. Install plugins.
  • 16. …AND MORE STEPS…AND MORE STEPS Select the theme. Install plugins. Configure plugins in WordPress admin interface.
  • 17. …AND MORE STEPS…AND MORE STEPS Select the theme. Install plugins. Configure plugins in WordPress admin interface. Set API keys (eg. MailChimp, Google Maps, etc.)
  • 18. …AND MORE STEPS…AND MORE STEPS Select the theme. Install plugins. Configure plugins in WordPress admin interface. Set API keys (eg. MailChimp, Google Maps, etc.) Import data
  • 19. …AND MORE STEPS…AND MORE STEPS Select the theme. Install plugins. Configure plugins in WordPress admin interface. Set API keys (eg. MailChimp, Google Maps, etc.) Import data …
  • 20. …AND MORE STEPS…AND MORE STEPS Select the theme. Install plugins. Configure plugins in WordPress admin interface. Set API keys (eg. MailChimp, Google Maps, etc.) Import data … Create pages for the theme templates.
  • 21.
  • 22. WHAT ARE WE GOING TO AUTOMATE?WHAT ARE WE GOING TO AUTOMATE?
  • 23. WHAT ARE WE GOING TO AUTOMATE?WHAT ARE WE GOING TO AUTOMATE? 1. Infrastructure setup.
  • 24. WHAT ARE WE GOING TO AUTOMATE?WHAT ARE WE GOING TO AUTOMATE? 1. Infrastructure setup. 2. WordPress configuration.
  • 25. WHAT ARE WE GOING TO AUTOMATE?WHAT ARE WE GOING TO AUTOMATE? 1. Infrastructure setup. 2. WordPress configuration. 3. WordPress data.
  • 26. BENEFITS OF AUTOMATIONBENEFITS OF AUTOMATION Why do we want to automate things?
  • 27. BENEFITS OF AUTOMATIONBENEFITS OF AUTOMATION Why do we want to automate things? Because developers are lazy?
  • 28. BENEFITS OF AUTOMATIONBENEFITS OF AUTOMATION Why do we want to automate things? Because developers are lazy? Multi-environments (staging, QA, production, …)
  • 29. BENEFITS OF AUTOMATIONBENEFITS OF AUTOMATION Why do we want to automate things? Because developers are lazy? Multi-environments (staging, QA, production, …) Server configuration consistency.
  • 30. BENEFITS OF AUTOMATIONBENEFITS OF AUTOMATION Why do we want to automate things? Because developers are lazy? Multi-environments (staging, QA, production, …) Server configuration consistency. Avoids « It works on my machine ¯_( )_/¯ ».
  • 31. BENEFITS OF AUTOMATIONBENEFITS OF AUTOMATION Why do we want to automate things? Because developers are lazy? Multi-environments (staging, QA, production, …) Server configuration consistency. Avoids « It works on my machine ¯_( )_/¯ ». Easy versioning.
  • 32. BENEFITS OF AUTOMATIONBENEFITS OF AUTOMATION Why do we want to automate things? Because developers are lazy? Multi-environments (staging, QA, production, …) Server configuration consistency. Avoids « It works on my machine ¯_( )_/¯ ». Easy versioning. Continuous Integration and Deployment.
  • 33. BENEFITS OF AUTOMATIONBENEFITS OF AUTOMATION Why do we want to automate things? Because developers are lazy? Multi-environments (staging, QA, production, …) Server configuration consistency. Avoids « It works on my machine ¯_( )_/¯ ». Easy versioning. Continuous Integration and Deployment. Streamline team work.
  • 34. BENEFITS OF AUTOMATIONBENEFITS OF AUTOMATION Why do we want to automate things? Because developers are lazy? Multi-environments (staging, QA, production, …) Server configuration consistency. Avoids « It works on my machine ¯_( )_/¯ ». Easy versioning. Continuous Integration and Deployment. Streamline team work. Faster and predictable deployments.
  • 35. BENEFITS OF AUTOMATIONBENEFITS OF AUTOMATION Why do we want to automate things? Because developers are lazy? Multi-environments (staging, QA, production, …) Server configuration consistency. Avoids « It works on my machine ¯_( )_/¯ ». Easy versioning. Continuous Integration and Deployment. Streamline team work. Faster and predictable deployments. "Cloud-ready".
  • 37.
  • 38. QUICK INTRODUCTION ON DOCKERQUICK INTRODUCTION ON DOCKER
  • 39. QUICK INTRODUCTION ON DOCKERQUICK INTRODUCTION ON DOCKER "Lightweight virtualisation".
  • 40. QUICK INTRODUCTION ON DOCKERQUICK INTRODUCTION ON DOCKER "Lightweight virtualisation". Each service runs in a separate Docker container.
  • 41. QUICK INTRODUCTION ON DOCKERQUICK INTRODUCTION ON DOCKER "Lightweight virtualisation". Each service runs in a separate Docker container. Many services already have official images.
  • 42. QUICK INTRODUCTION ON DOCKERQUICK INTRODUCTION ON DOCKER "Lightweight virtualisation". Each service runs in a separate Docker container. Many services already have official images.
  • 43. QUICK INTRODUCTION ON DOCKERQUICK INTRODUCTION ON DOCKER "Lightweight virtualisation". Each service runs in a separate Docker container. Many services already have official images. Rule of thumb: one service per container.
  • 44. QUICK INTRODUCTION ON DOCKERQUICK INTRODUCTION ON DOCKER "Lightweight virtualisation". Each service runs in a separate Docker container. Many services already have official images. Rule of thumb: one service per container. Works on Linux, Windows, MacOS.
  • 45. DOCKER: BENEFITSDOCKER: BENEFITS Very handy for local development and for servers. Documents and versions the infrastructure of the project. Allows to install any version of any dependency. Easy to update configuration for all environmnents. Isolation of projects. Easy to deploy.
  • 46. CONTAINERS FOR WORDPRESSCONTAINERS FOR WORDPRESS File system link Network link Project files
  • 47. SETTING UP DOCKER CONTAINERSSETTING UP DOCKER CONTAINERS docker-compose.yml file at the root of the project: services: wordpress: image: wordpress:5.2-php7.3-fpm-alpine # ... database: image: mysql:5.7 # ... webserver: image: nginx:1.14-alpine # ...
  • 49. database: image: mysql:5.7 1 2 restart: always3 volumes:4 - db_data:/var/lib/mysql5 environment:6 MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}7 MYSQL_DATABASE: ${MYSQL_DATABASE}8 MYSQL_USER: ${MYSQL_USER}9 MYSQL_PASSWORD: ${MYSQL_USER_PASSWORD}10 ports:11 - 3306:330612
  • 50. restart: always database:1 image: mysql:5.72 3 volumes:4 - db_data:/var/lib/mysql5 environment:6 MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}7 MYSQL_DATABASE: ${MYSQL_DATABASE}8 MYSQL_USER: ${MYSQL_USER}9 MYSQL_PASSWORD: ${MYSQL_USER_PASSWORD}10 ports:11 - 3306:330612
  • 51. environment: MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} MYSQL_DATABASE: ${MYSQL_DATABASE} MYSQL_USER: ${MYSQL_USER} MYSQL_PASSWORD: ${MYSQL_USER_PASSWORD} database:1 image: mysql:5.72 restart: always3 volumes:4 - db_data:/var/lib/mysql5 6 7 8 9 10 ports:11 - 3306:330612
  • 52. webserver: image: nginx:1.14-alpine links: - wordpress volumes: - wordpress_data:/var/www/html - ./docker/nginx/website.conf:/etc/nginx/conf.d/default.conf: ports: - ${WEBSERVER_PORT}:80
  • 54. ENVIRONMENT VARIABLESENVIRONMENT VARIABLES Specific to an environment. Examples: Database parameters Website URLs (eg. root URL of the website, API endpoint, etc.) Email recipients May contain sensitive data. Can be set in: A .env file In CI/CD tools like Travis, TeamCity, etc. Not commited in the project.
  • 56. LET'S RUN ITLET'S RUN IT One command to start Docker containers: docker-compose up -d
  • 57. LET'S RUN ITLET'S RUN IT One command to start Docker containers: All services are up and running: + docker-compose up -d
  • 58.
  • 59. ADDING SERVICES IS EASYADDING SERVICES IS EASY Want phpMyAdmin? Update docker-compose.yml: Access it at services: # ... phpmyadmin: image: phpmyadmin/phpmyadmin links: - database:db ports: - 8082:80 http://localhost:8082
  • 61. DITCH THE WIZARDDITCH THE WIZARD Set the language. Add default admin user. Configure database parameters. Define posts URL structure. Choose a theme. Install plugins.
  • 62. WP-CLIWP-CLI WP-CLI provides a command-line interface for many actions you might perform in the WordPress admin. wp-cli.org
  • 63. USEFUL WP-CLI COMMANDSUSEFUL WP-CLI COMMANDS Generate a wp-config.php file with DB parameters: Run the standard WordPress installation process: Install and activate plugins: wp-cli config create --dbhost=… --dbname=… <...> wp-cli core install --url=… --title=… wp-cli plugin install contact-form-7 --activate wp-cli plugin install advanced-custom-fields --activate
  • 64. HOW TO INSTALLHOW TO INSTALL Requirements for running WP-CLI: A PHP installation. Installing it (on every environment). Access to the WordPress directory.
  • 65. HOW TO INSTALLHOW TO INSTALL Requirements for running WP-CLI: A PHP installation. Installing it (on every environment). Access to the WordPress directory. Let's use a Docker container!
  • 66. WP-CLI IN A DOCKER CONTAINERWP-CLI IN A DOCKER CONTAINER toolbox: image: michaelperrin/wordpress-toolbox volumes: - wordpress_data:/wordpress - ./Makefile:/scripts/Makefile depends_on: - database environment: MYSQL_HOST: ${MYSQL_HOST} MYSQL_DATABASE: ${MYSQL_DATABASE} MYSQL_USER: ${MYSQL_USER} MYSQL_USER_PASSWORD: ${MYSQL_USER_PASSWORD} WORDPRESS_ADMIN_EMAIL: ${WORDPRESS_ADMIN_EMAIL} WORDPRESS_ADMIN_PASSWORD: ${WORDPRESS_ADMIN_PASSWORD} WORDPRESS_ADMIN_USER: ${WORDPRESS_ADMIN_USERNAME} WORDPRESS_DOMAIN_NAME: ${WORDPRESS_DOMAIN_NAME} WORDPRESS_WEBSITE_URL: ${WORDPRESS_WEBSITE_URL} WORDPRESS_LOCALE: en_US WORDPRESS_WEBSITE_POST_URL_STRUCTURE: "/%year%/%monthnum%/%day%/%postname WORDPRESS_WEBSITE_TITLE: "My beautiful website"
  • 67. - PHP - WP-CLI - Makefile File system link Network link Project files
  • 68. MAKEFILEMAKEFILE A file containing a set of scripts grouped as tasks. Abstracts and groups commands. The file is versioned in the project. Run: make task_one task_one: # ... task_two: # ... task_three: task_one task_two # ...
  • 69. MAKEFILE FOR OUR PROJECTMAKEFILE FOR OUR PROJECT install: start configure install_plugins set_theme start: docker-compose up -d stop: docker-compose stop configure: # ... (several WP-CLI commands) set_theme: docker-compose run --rm toolbox wp-cli theme activate my-simple-t install_plugins: # ... (one WP-CLI command per plugin)
  • 70. ONE COMMANDONE COMMAND Create Docker containers for WordPress, MySQL and Nginx. Initiate the WordPress database. Configure WordPress: Database parameters. Default WordPress user. Set language. Set default URL structure. Activate the custom `my-simple-theme` theme. Install plugins (Contact Form 7 and WP MailChimp as examples). make install
  • 71.
  • 73. DATA MIGRATION EXAMPLESDATA MIGRATION EXAMPLES Remove WordPress default content. Add page and menu entries. Configure plugins Add a contact form (Contact Form 7) Define MailChimp API key …
  • 75. WP-MIGRATIONS PLUGINWP-MIGRATIONS PLUGIN Inspired by for PHP and SQLDoctrine Migrations
  • 76. WP-MIGRATIONS PLUGINWP-MIGRATIONS PLUGIN Inspired by for PHP and SQL Runs user-defined migration files to describe data changes. Doctrine Migrations
  • 77. WP-MIGRATIONS PLUGINWP-MIGRATIONS PLUGIN Inspired by for PHP and SQL Runs user-defined migration files to describe data changes. Embeds a WP-CLI command to execute migrations. Doctrine Migrations
  • 78. ANATOMY OF A MIGRATIONANATOMY OF A MIGRATION <?php namespace Migration; use WPMigrationMigrationInterface; class Migration201909221755 implements MigrationInterface { public function execute() { // ... } }
  • 79. MIGRATION FILESMIGRATION FILES Stored in wp-content/migrations Only executed once. Should be committed to version control. Executed on deployment.
  • 80. EXAMPLEEXAMPLE public function execute() { $pageData = [ 'post_name' => 'about', // Permalink 'post_title' => 'About us', 'post_content' => '', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page', 'menu_order' => 1, ]; $postId = wp_insert_post($pageData); $this->addToMenu($postId, 'Contact'); } class Migration201909221755 implements MigrationInterface {1 use MigrationUtilitiesTrait;2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 }19
  • 81. EXAMPLE 2EXAMPLE 2 class Migration201905311454 implements MigrationInterface { public function execute() { $this->setMailChimpApiKey(getenv('MAILCHIMP_API_KEY')); } private function setMailChimpApiKey(string $key) { $options = get_option('mc4wp'); $options['api_key'] = $key; update_option('mc4wp', $options); } }
  • 82. RUN THE MIGRATIONSRUN THE MIGRATIONS make wordpress_migrations_execute
  • 83. RUN THE MIGRATIONS, AGAINRUN THE MIGRATIONS, AGAIN make wordpress_migrations_execute
  • 84. BENEFITS OF MIGRATIONSBENEFITS OF MIGRATIONS Structural changes are versioned. Facilitate team work and easy to deploy. No "in-between" state Multi-environments (using environment variables)
  • 85.
  • 86. FINAL TREE STRUCTUREFINAL TREE STRUCTURE Only what our project needs. Easy versioning. Includes infrastructure & all automations.
  • 87.
  • 88. THANK YOU!THANK YOU! Twitter: Demo repository: Slides (soon): @michael_perrin https://github.com/michaelperrin/automated- wordpress-demo http://blog.michaelperrin.fr/