Top Banner
Beyond FTP WORDCAMP NOLA - AUGUST 13, 2016 ELI SILVERMAN - CALIPER CREATIVE
55

Beyond FTP: What I’ve Learned from Years of Deploying WordPress the Wrong Way

Jan 17, 2017

Download

Technology

Eli Silverman
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

Beyond FTPW O R D C A M P N O L A - A U G U S T 1 3 , 2 0 1 6

E L I S I L V E R M A N - C A L I P E R C R E A T I V E

Page 2: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

W O R D C A M P N O L A - A U G U S T 1 3 , 2 0 1 6

Or: What I’ve Learned from Years of Deploying

WordPress the Wrong Way

E L I S I L V E R M A N - C A L I P E R C R E A T I V E

Page 3: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

it me!

CALIPER

I build websites, design for both screen and print, create web-based software and business tools, and offer creative direction for digital and physical design projects.

Caliper works with businesses to establish strong brands and fluid workflows.

Page 4: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP | OVERVIEW

Q: Do you rely on WordPress to make a living?

Page 5: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

´

BEYOND FTP |

My main goal is to expose more of the WordPress community to really powerful development tools in a way that aren’t intimidating and can be quickly adopted and installed.

OVERVIEW

You deserve the best tools.

Page 6: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

´

BEYOND FTP |

� What it looks like to sync WordPress installs in seconds.

� What “software deployment” means, and specifically what it means in WordPress.

� Show you why, if you love FTP, it’s time to let it go.

� How WP devs can use tools from the non-WP world.

� How quickly you can start using the toolkit.

OVERVIEW

WHAT YOU’LL SEE TODAY

Page 7: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP | OVERVIEW

Q: Who’s seen WordPress managed from the command line?

Page 8: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

´

BEYOND FTP |

THIS IS HOW YOU DEPLOY STARTING TODAY:

OVERVIEW

Page 9: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

B E Y O N D F T P - W O R D C A M P N O L A - A U G U S T 1 3 , 2 0 1 6

Breaking Bad (Habits)

Page 10: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

You can pretty much deliver a WP website without knowing how to write a word of code.

But if you dive deeper into WordPress through a Cut-and-Paste Education, it can prevent you from becoming a better developer.

BREAKING BAD (HABITS)

WP IS SUPER EASY TO WORK WITH, BUT THAT CAN LEAD TO BAD PRACTICE.

I learned this the hard way.

Page 11: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

Working against a deadline for my first “legit” client, my workflow failed me…big time.

BREAKING BAD (HABITS)

Page 12: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

Q: Has this ever happened to anyone else?

BREAKING BAD (HABITS)

A: Yes. To Everyone.

Page 13: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

My inexperience wasn’t cute anymore.

It was a glaring liability.

BREAKING BAD (HABITS)

Page 14: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

I had been working in a vacuum and I had no mentor to show me the ropes, or point out the things I was doing totally wrong.

FREELANCERS ARE ALONE. A LOT.

BREAKING BAD (HABITS)

Page 15: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

Desperately, I thought:

“Other developers MUST have a better way.”

Turns out, they do.

BREAKING BAD (HABITS)

Page 16: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

B E Y O N D F T P - W O R D C A M P N O L A - A U G U S T 1 3 , 2 0 1 6

“Deployment”

Page 17: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

´

BEYOND FTP |

“all of the activities that make a software system available for use”

“DEPLOYMENT”

WHAT…IS… DEPLOYMENT?

(WikiPedia)

Page 18: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

´

BEYOND FTP |

AND WHAT DOES THAT MEAN IN WORDPRESS?

our “software system” is both thefiles and the database.

core, themes, plugins, uploaded content

customization, post content, session data

“DEPLOYMENT”

Page 19: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

Q: Do you develop locally and push code to a remote server?

“DEPLOYMENT”

Page 20: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

´

BEYOND FTP |

THEN YOU KNOW THIS LIST…

“DEPLOYMENT”

Install WordPress. DB up and running. All plugins are installed and configured…The theme is installed (including the parent) and customized properly…The uploads are all there…

I’M. SO. BORED.

Page 21: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

´

BEYOND FTP | “DEPLOYMENT”

CANT WE MAKE OUR MACHINES DO ALL THIS, AHEM, GRUNT WORK FOR US?

Page 22: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

B E Y O N D F T P - W O R D C A M P N O L A - A U G U S T 1 3 , 2 0 1 6

Why You Haven’t Left FTP Behind

The Excuses:

Page 23: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

“IT’S OVER MY HEAD”

FTP EXCUSES

But, before you knew how to swim, so did the deep end.

$ ../I/know/the --command line_seems SCARY.

Page 24: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

Just like any text editor, you can take control of the command line and let it adapt to you.

� iTerm � oh-my-zsh � aliases

$ htdocs client

$ cd /Applications/MAMP/htdocs/clientsite.com/wp-content/themes/my-clients-theme/

instead of

“IT’S OVER MY HEAD”

FTP EXCUSES

Page 25: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

“it’s such a timesaver that any time I spent setting it up, I got back immediately after it was working, and then some…”

“IT TAKES TOO LONG TO SETUP”

- Paid Actor, Not a real Doctor

FTP EXCUSES

Page 26: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

“I’M NOT A DEVELOPER AND I HAVE BETTER THINGS TO LEARN”

If you’re spending even a few hours a week messing WordPress – even content or theme config – this is worth your while. And if you’re writing code maybe it’s time you start calling yourself a developer…

FTP EXCUSES

Page 27: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

Instead of WordPress, let’s say I work as a lumberjack.

rChoppin wood all damn day.

HOW IT LOOKS IN ANOTHER INDUSTRY

FTP EXCUSES

Page 28: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

This is me trying to do my job done with the wrong tools…

FTP EXCUSES

Page 29: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

This is me trying to do my job done with the wrong tools…

FTP EXCUSES

Page 30: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

and here’s me with the right tools, gettin paid and clockin out…

FTP EXCUSES

Page 31: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

Note: I do not endorse deforestation

FTP EXCUSES

Page 32: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

NOW THAT YOU HAVE A CHOICE, WHICH ONE

DO YOU CHOOSE?

FTP EXCUSES

Page 33: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

B E Y O N D F T P - W O R D C A M P N O L A - A U G U S T 1 3 , 2 0 1 6

Deployment for WordPress “In the Wild”

Page 34: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

The deploy needs to transfer the “software system” ( files & db )

OUR CRITERIA

Needs to work on (or help with) crappy $2/mo hosting services that a lot of are FORCED to use with clients.

IN THE WILD

1.

2.

Page 35: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

RESEARCH & IMPLEMENTATIONRoots’ Trellis is an amazing solution but caters to devs deploying enterprise-grade WP apps.

Most likely, it won’t work with a cheap shared-server, and it’s tied to git, which is “smarter” but not what I wanted.

IN THE WILD

Page 36: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

&

I K N O W , I K N O W . G U L P I S C O O L E R . P L E A S E , W R I T E A P O R T , P L Z …

. / WP-CLI

IN THE WILD

Page 37: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

I was already using grunt.js for CSS + JS processing.

Found and forked grunt-wordpress-deploy on npm (node package manager)

Dario Ghilardi – @webrain on github

GRUNT.JS

IN THE WILD

Javascript “task runner”

Page 38: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

๏ Many times faster than FTP (like, 100x) ๏ Intelligent: only touches files that changed ๏ Repeatable, reliable, configurable

IN THE WILD

GRUNT WORDPRESS DEPLOY

Uses rsync, a standard command line file syncing service, and it’s a huge step up from FTP.

Page 39: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

$ grunt sync_up --target=dev

ANATOMY OF A GRUNT “CALL”

IN THE WILD

Page 40: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

$ grunt sync_up --target=dev

“$” often represents cmd line. Don’t type this!

run the grunt “executable”

the grunt “task” you want to execute

sets the server “target” flag (variable) to our “dev” environment.

ANATOMY OF A GRUNT “CALL”

IN THE WILD

Page 41: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

Made for WP using SSH/rsync

• push all local plugins • push all local uploads • build + compress theme/plugin • push theme/plugin • push the database

GRUNT WORDPRESS DEPLOY

IN THE WILD

grunt sync_up

Page 42: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

• Creates a clean folder that you deploy from – fallback for FTP

• Simple versioning : creates “releases” – deliver to client, upload via wp-admin, don’t need to know git

GRUNT WORDPRESS DEPLOY

IN THE WILD

Made for WP in The Wild

grunt build

Page 43: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

GRUNT WORDPRESS DEPLOY • build

• push_theme • push_files • push_plugin • push_plugins • deploy

• push_db • pull_db

• sync_up

Other grunt Tasks

MANAGING FILES MANAGING THE DB

ALL THE THINGS

IN THE WILD

Page 44: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

“WP-CLI is a set of command-line tools for managing WordPress installations. You can update plugins, configure multisite installs and much more, without using a web browser.”

WP-CLI

(wp-cli.org)

IN THE WILD

Page 45: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

$ wp plugin install query-monitor

ANATOMY OF A BASIC WP-CLI

IN THE WILD

Page 46: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

$ wp plugin install query-monitor

run the wp-cli “executable”

the wp thing “type” you want to manipulate

the action you want to perform with that thing

additional info. In this case, the plugin slug from the wp plugins directory

ANATOMY OF A BASIC WP-CLI

IN THE WILD

Page 47: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

BROWSER REFRESH GOT YA DOWN?

No need to click around in wp-admin every time you need to de/activate a plugin. Want to see if that new slider plugin is causing the site to break?

$ wp plugin deactivate acme-slider

$ dp acme-slider

or with my “deactivate-plugin” alias

IN THE WILD

Page 48: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

ALIASES As of very recently, you can specify a remote target WP install using wp-cli aliases.

$ wp @dev plugin deactivate query-monitor

alias name, defined in config “ssh: [email protected]/remote/wp/path”

MORE WP-CLI AWESOMENESS

IN THE WILD

View Config Docs

Page 49: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

B E Y O N D F T P - W O R D C A M P N O L A - A U G U S T 1 3 , 2 0 1 6

Getting it Running

Page 50: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

I MADE YOU A THING!

BOILERPLATE

A github project that makes it super easy to get this up and running.

I. Follow the 4 steps on github to install II. Add your DB and SSH details to the config III. Test using the —dry-run flag IV. Get to work!

https://github.com/madebycaliper/grunt-wp-deploy-boilerplate

Page 51: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

REQUIREMENTS

✓ SSH access w/key ✓ WP core installed ✓ WP database setup ✓ mysql command line

wp-cli installed (optional)

✓ git ✓ rsync (bundled w/OS X)

✓ node.js + npm ✓ SSH key configured ✓ MAMP or comparable ✓ WordPress Installed

wp-cli installed (optional)

Local Remote

BOILERPLATE

Page 52: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP |

GRUNT DEPLOY AND WP-CLI DEMO

BOILERPLATE

Page 53: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

BEYOND FTP | CONCERNS

๏ This method is not tied to version control like Capistrano or Deploy HQ. You cannot auto “roll back” to a previous version.

✓ You can checkout a local commit and just run ‘grunt deploy’

๏ Still some chance of human error, it’s possible to overwrite files (these are irreversible operations)

✓ Play it safe by enabling rsync’s --dry-run flag first – shows you what files will be changed without doing it.

๏ MySQL and PHP configs can vary between hosts and create errors with the DB operations (command line outputs unexpected strings/results)

✓ Use the ‘sql_remove’ option in the wordpresdeploy.coffee file to sanitize output

๏ This hasn’t been tested on very large databases. Test it out for me?

๏ I’ve only ever done this on a Mac/linux. Not sure how rsync works on windows.

CONCERNS

Page 54: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

´

BEYOND FTP |

THANK YOU!

๏ More command line tips for WordPress ๏ Debugging PHP (Sublime Text + Xdebug) ๏ Debugging JS in the Chrome DevTools ๏ Version control with git and SourceTree ๏ Advanced use of the wp-cli

MadeByCaliper.com

MIC DROP

There’s so much more for WordPress developers. Improve your workflow, understanding of code, and know how to quickly troubleshoot WP/PHP:

Page 55: Beyond FTP:  What I’ve Learned from Years of Deploying WordPress the Wrong Way

Beyond FTPW O R D C A M P N O L A - A U G U S T 1 3 , 2 0 1 6