the wordpress hacker's guide to the \galaxy() [@baltimore php]

76
The WordPress Hacker’s Guide to the \Galaxy() Wednesday, February 20, 13

Upload: jason-rhodes

Post on 17-Dec-2014

209 views

Category:

Technology


0 download

DESCRIPTION

As someone who started with PHP as a self-described "WordPress hacker", I had a hard time finding the path to becoming a knowledgeable programmer. Having now stumbled a short way up that path, I think we can make it easier for anyone who's interested in finding it. I'll share a brief overview of the tools and concepts I wish I'd known getting started, including why the command line matters, how version control fits with WP, MVC architecture, interfaces/adapters, general PHP tips, etc.

TRANSCRIPT

Page 1: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

The WordPress Hacker’s Guide to the \Galaxy()

Wednesday, February 20, 13

Page 2: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

The Person Who Is Interested In Learning More About PHP

But Doesn’t Have Much Experience With Code or

Programming’s

Guide to the \Galaxy()Wednesday, February 20, 13

Page 3: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

The WordPress Hacker’s Guide to the \Galaxy()

Wednesday, February 20, 13

Page 4: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

@rhodesjasongithub.com/jasonrhodesnotrobotic.com

Wednesday, February 20, 13

Page 5: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

uncharted backwaters

unfashionable end of the Western Spiral arm

of the Galaxy

a small unregarded yellow sun

utterly insignificant little blue-green planet

Wednesday, February 20, 13

Page 6: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 7: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 8: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 9: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

PHP is popular,

and people hate it.

Wednesday, February 20, 13

Page 10: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

PHP is an embarrassment, a blight upon my craft.

It’s so broken, but so lauded by every empowered amateur who’s yet to learn anything else, as to be maddening.

PHP is an embarrassment,

http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/

so lauded by every empowered amateur who’s yet to learn anything else

Wednesday, February 20, 13

Page 11: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

When faced with either doing something nonsensical or aborting with an error, it will do something nonsensical.

There’s no clear design philosophy.

PHP takes inspiration from other languages, yet still is incomprehensible to anyone who knows those languages.

Weak typing is so complex that whatever minor programmer effort is saved is by no means worth it.

There is a whole lot of action at a distance.

The language is full of global and implicit state.

There is no threading support whatsoever.

Parts of PHP are practically designed to produce buggy code.

Your program will not blow up; it will, instead, do the wrong thing with no warning…

PHP is a community of amateurs.

This, right here, is the biggest problem with PHP: it is absolutely the blind leading the blind.

There is no way to declare a variable.

There are no references. What PHP calls references are really aliases.

Variable names are case-sensitive. Function and class names are not.

There is no module system, even for PHP code.

PHP language problems as described at http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/

Wednesday, February 20, 13

Page 12: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

PHP is a community of amateurs.

Wednesday, February 20, 13

Page 13: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 14: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 15: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Terrible design buried under a mountain of spaghetti code

Reading through [WordPress code] is like jabbing red-hot fire pokeys into your eyes.

BEHOLD WORDPRESS, DESTROYER OF CPUS

remote shell with cms on side, aka: shit

shit plugins

WordPress is for cat pictures and diary entries.

code is crapcrapcrap

F$%@ THAT F$%@ THAT F$%@ THAT F$%@ THAT F$%@ THAT F$%@ THAT

WordPress is... just adequate

WordPress is for amateurs.

WordPress is... terrifyingly insecure.

No good default caching, it will kill your server if you don’t know what you’re doing

Stack Overflow spam questions

Not a “real” CMS and definitely not a “real” framework

WordPress problems as described by various PHP developers

A really terrible database structure

Wednesday, February 20, 13

Page 16: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

WordPress is for amateurs.

Wednesday, February 20, 13

Page 17: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

=

Wednesday, February 20, 13

Page 18: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

WORDPRESS... IS PHP!!it’s PHP eating PHP?

Wednesday, February 20, 13

Page 19: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

PHP WILL MAKE ME BETTER AT WORDPRESS?!

Wednesday, February 20, 13

Page 20: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

EVERYTHING YOU NEED TO KNOW

ABOUT ANYTHING(PHP)

WP Hacker’s Guide

Wednesday, February 20, 13

Page 21: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

LTFCL

WP Hacker’s Guide #1

Wednesday, February 20, 13

Page 22: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 23: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 24: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 25: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Drush

Wednesday, February 20, 13

Page 26: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 27: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 28: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 29: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 30: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 31: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 32: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 33: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

INVEST IN A SAFETY NET

WP Hacker’s Guide #2

Wednesday, February 20, 13

Page 34: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

my-resume.docx

Wednesday, February 20, 13

Page 35: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

⌘S

my-resume.docx

Wednesday, February 20, 13

Page 36: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

my-resume.docx

Wednesday, February 20, 13

Page 37: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

my-resume.docx

⌘S

Wednesday, February 20, 13

Page 38: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

my-resume-alt-1.docx

⌘⇧S

Wednesday, February 20, 13

Page 39: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

my-resume-alt-1.docx SUCKS

CAN’T GET BACK HERE

CAN’T PUT IT BACK TOGETHER

my-resume.docx

Wednesday, February 20, 13

Page 40: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 41: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

+

Wednesday, February 20, 13

Page 42: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

FIND TRUSTED TRAVELERS

WP Hacker’s Guide #3

Wednesday, February 20, 13

Page 43: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

USERGROUP IRC STACK

OVERFLOW

Wednesday, February 20, 13

Page 44: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

KNOW YOUR SHIP(S)

WP Hacker’s Guide #4

Wednesday, February 20, 13

Page 45: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 46: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

$ brew install git

Wednesday, February 20, 13

Page 47: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 48: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

LEARN THE LANGUAGE

WP Hacker’s Guide #5

Wednesday, February 20, 13

Page 49: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

OOP + CALLBACKS

LEARN THE LANGUAGE

Wednesday, February 20, 13

Page 50: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

add_action(“action”, “function_name”);

CALLABLE

Wednesday, February 20, 13

Page 51: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

array($object, “method_name”)

Wednesday, February 20, 13

Page 52: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 53: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 54: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 55: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

MVCLEARN THE LANGUAGE

Wednesday, February 20, 13

Page 56: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Model

Wednesday, February 20, 13

Page 57: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Model

Wednesday, February 20, 13

Page 58: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

View

Wednesday, February 20, 13

Page 59: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

xActor 1

xActor 2

xActor 3

View

Wednesday, February 20, 13

Page 60: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Controller

Wednesday, February 20, 13

Page 61: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

<?php

mysite.com/categories/recipes

Wednesday, February 20, 13

Page 62: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

mysite.com/categories/recipes

Wednesday, February 20, 13

Page 63: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

DILEARN THE LANGUAGE

Wednesday, February 20, 13

Page 64: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 65: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

MEANWHILE, IN ANOTHER PLUGIN...

Wednesday, February 20, 13

Page 66: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 67: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

FATAL ERROR

Wednesday, February 20, 13

Page 68: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 69: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 70: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 71: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

To review:

LTFCLINVEST IN A SAFETY NETFIND TRUSTED TRAVELERSKNOW YOUR SHIP(S)LEARN THE LANGUAGE

Wednesday, February 20, 13

Page 72: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

Wednesday, February 20, 13

Page 73: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

GOOGLE EXISTS

Wednesday, February 20, 13

Page 74: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

YOUR CODE WILL SUCKAnd nobody will die.

(Probably.)

Wednesday, February 20, 13

Page 75: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

EVERYONE ELSE’SCODE SUCKS TOO

Wednesday, February 20, 13

Page 76: The WordPress Hacker's Guide to the \Galaxy() [@Baltimore PHP]

@rhodesjasongithub.com/jasonrhodes

Slides, notes, and bad code:notrobotic.com/talks/wpgalaxy

Wednesday, February 20, 13