Upload
eli-silverman
View
347
Download
1
Embed Size (px)
Citation preview
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
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
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.
´
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.
´
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
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.
BEYOND FTP |
Working against a deadline for my first “legit” client, my workflow failed me…big time.
BREAKING BAD (HABITS)
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)
BEYOND FTP |
Desperately, I thought:
“Other developers MUST have a better way.”
Turns out, they do.
BREAKING BAD (HABITS)
´
BEYOND FTP |
“all of the activities that make a software system available for use”
“DEPLOYMENT”
WHAT…IS… DEPLOYMENT?
(WikiPedia)
´
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”
´
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.
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:
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.
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
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
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
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
BEYOND FTP |
This is me trying to do my job done with the wrong tools…
FTP EXCUSES
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”
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.
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
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
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”
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.
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
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
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
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
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
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
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
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
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
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
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
´
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: