The Original Hypertext Preprocessor

A presentation at PHP Community Conference in April 2011 in Nashville, TN, USA by Drew McLellan

Slide 1

Slide 1

PHP Community Conference 22nd April 2011 Drew McLellan edgeofmyseat.com grabaperch.com -THE ORIGINAL- HYPERTEXT PREPROCESSOR

Slide 2

Slide 2

EVERY LINE OF CODE

-CAN HAVE A-

DIRECT IMPACT

ON USERS This is what I’m talking about today

Slide 3

Slide 3

DESIGNING SOFTWARE

  • FOR - HUMANS In the purest sense. Not just designing to perform a functional task. To enable users to perform that task SUCCESSFULLY.

Slide 4

Slide 4

FUNCTIONALITY -IS NOT - ENOUGH Providing functionality is a starting point. Yes it has to be usable. But it also has to be USED. Dusty software == failure.

Slide 5

Slide 5

REWIND Let’s rewind. Perch is a small PHP and MySQL based CMS. It’s been developed as a commercial product. I’m going to be talking about my experience developing it. To share experience, not sell to you!

Slide 6

Slide 6

DUD E!

LIKE WHAT ABOUT

DRUPAL? WAIT! Why a PHP CMS?! There are a lot of PHP CMSs. Drupal, Wordpress, Joomla... opensourcecms.com lists 250 of them. But we keep coming across experiences like this:

Slide 7

Slide 7

“ With Wordpress (don’t even get me started on Drupal), the learning curve was very high, requiring my clients to learn about posts versus pages versus custom post types. ” This story is very common. Lots of capable software available, but FUNCTIONALITY IS NOT ENOUGHT. People find their clients can’t use it.

Slide 8

Slide 8

DOZENS OF

OPTIONS MILLIONS OF

USERS Just because a lot of similar things exist, it doesn’t mean the market is too crowded.

Slide 9

Slide 9

THERE 'S ROOM

IF YOU CAN BE

DIFFERENT This applies to Open Source projects as much as commercial products. Don’t be afraid of finding a new way to solve a problem that has already been solved.

Slide 10

Slide 10

LIGHTWEIGHT
PHP CMS

FOR SMALL WEBSITES We decided to go ahead. 
 Focussing on a market of web designers building small sites for their clients. Portfolios, restaurants, guest houses, clubs, places of worship.

Slide 11

Slide 11

LISTEN U P! CLASS IN SESSION I’ve split this up into lessons we’ve learned.

Slide 12

Slide 12

  • THE MOST -

DIFFICULT

PROBLEMS

  • ARE THE - WET ONES

Slide 13

Slide 13

Support will kick your ass. Jason Fried, 37signals http://www.extractable.com/blog/?p=58

Slide 14

Slide 14

Helpspot really saved our ass when it came to support. Todd Dominey, SlideShowPro
http://5by5.tv/bigwebshow/24

Slide 15

Slide 15

SUPPORT

INVOLVES

  • A LOT OF - ASSES

Slide 16

Slide 16

MANY CUSTOMERS

ARE INEXPERIENCED When it comes to installing and deploying PHP apps - or any. Typically just HTML, CSS, FTP users.

Slide 17

Slide 17

THEY NEED
A LOT OF SUPPORT We're a service-based company. We don't have time to deal with a lot of support.

Slide 18

Slide 18

EACH LICENSE SOLD 30 MINUTES OF SUPPORT TIME Financially, each license has max 15 mins support. Of course, that’s not the reality

Slide 19

Slide 19

  • FIND WAYS TO -

REDUCE

SUPPORT REQUESTS We needed to find ways to make sure that this was actually profitable. That’s important for us commercially, but it’s also the sort of thing that’s important for OSS. How often does a “strong community” == “hard to use software”.

Slide 20

Slide 20

EVERY REQUEST SHOULD BE

UNIQUE No question should need to be asked twice - every request should be unique

Slide 21

Slide 21

SUPPORT

YOUR OWN

SOFTWARE Developers should support their own software Then you’re exposed to the important problems. Helps to prioritise what to work on. The bugs causing users issues are more important than anything else.

Slide 22

Slide 22

  • WHEN -

WILL THIS FAI L?

  • Every line of code has the potential to create a support request
  • robustness
  • di " erent configurations
  • clear wording
  • when will this fail?

Slide 23

Slide 23

Some fixes can be as simple as microcopy

Slide 24

Slide 24

Slide 25

Slide 25

This used to be a very common support request.

Slide 26

Slide 26

The change of wording eliminated this request almost entirely. The next step is validation on the license key format.

Slide 27

Slide 27

ALL CODE BREAKS. GREAT CODE

BREAKS WELL Anticipate when the code will fail and design for it. This is important in uncontrolled environments like other people’s hosting.

Slide 28

Slide 28

NOT ALL ATTEMPTS

ARE SUCCESSFUL It doesn’t always work as planned

Slide 29

Slide 29

Slide 30

Slide 30

SPEED OF RESPONSE

IS THE MOST IMPORTANT

THING

Slide 31

Slide 31

TECHNICAL PROBLEMS

  • ARE - DIFFICULT TOO We said the most di

cult problems are wet ones. Technical problems are hard too.

Slide 32

Slide 32

PHP5 AS STANDARD We chose to standardise PHP5 Thinking we’d exclude some people. We considered developing 2 parallel versions. As it turns out this was a non-issue. Any host on PHP4 these days o " ers upgrades.

Slide 33

Slide 33

WE WOULD LOVE

  • TO MOVE TO -

PHP5.3 Particularly for Phar support. Easier deployment

Slide 34

Slide 34

THE FAILED PROMISE OF SQLITE We wanted to use SQLite to make configuration easier It actually makes configuration harder. DB needs to be protected or outside the web root. Hard when you don’t control the hosting.

Slide 35

Slide 35

SCHEMALESS

STRUCTURED DATA We store structured data without a schema in MySQL

Slide 36

Slide 36

<perch:content
type=”text” id=”heading” label=”Main heading” required=”true” />

Slide 37

Slide 37

<h2> <perch:content id="heading" type="text" label="Heading" required="true" title="true" /> </h2> <p class="date"> <perch:content id="date" type="date" label="Date" format="%d %B %Y" /> </p> <perch:content id="body" type="textarea" label="Body" textile="true" editor="markitup" required="true" /> We take whatever content the user gives and need to be able to store it. This would be perfect for a NOSQL database, but those aren’t common on typical hosting.

Slide 38

Slide 38

TABLE OF KEY-VALUE PAIRS

  • OR - BIG BLOB OF
    JSON

Slide 39

Slide 39

TABLE OF KEY-VALUE PAIRS

Slide 40

Slide 40

SCALES UP WELL CAN BE
FILTERED WITH SQL

  • a big table of name/value pairs
  • scales up well
  • can be filtered with SQL (although awkwardly)
  • requires housekeeping
  • uses mediumtext to store a boolean

Slide 41

Slide 41

  • REQUIRES - HOUSEKEEPING INEFFICIENT FOR SMALL VALUES
  • a big table of name/value pairs
  • scales up well
  • can be filtered with SQL (although awkwardly)
  • requires housekeeping
  • uses mediumtext to store a boolean

Slide 42

Slide 42

BIG BLOB OF
JSON

Slide 43

Slide 43

STORE ANY SHAPE DATA IN ONE ROW EXTREMELY SIMPLE

Slide 44

Slide 44

CONTENT HAS TO BE FILTERED IN PHP NATIVE JSON LIBRARIES

ARE NOT YET UNIVERSAL

Slide 45

Slide 45

CREATE TABLE perch_contentItems ( contentID int(10) unsigned NOT NULL AUTO_INCREMENT, contentKey varchar(255) NOT NULL DEFAULT '', contentPage varchar(255) NOT NULL DEFAULT '*', contentHTML longtext NOT NULL, contentNew tinyint(1) unsigned NOT NULL DEFAULT '1', contentTemplate varchar(255) NOT NULL DEFAULT '', contentMultiple tinyint(1) unsigned NOT NULL DEFAULT '0', contentAddToTop tinyint(1) unsigned NOT NULL DEFAULT '0', contentJSON mediumtext NOT NULL, contentHistory mediumtext NOT NULL, contentOptions text NOT NULL, PRIMARY KEY (contentID), KEY idx_key (contentKey), KEY idx_page (contentPage) ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

Slide 46

Slide 46

SO, UM, HOW'S THAT WORKING OUT FOR YO U? It’s not ideal! The original requirement of storing schemaless data works!

Slide 47

Slide 47

NON-NATIVE JSON IS SLOW We use the PEAR JSON libraries if native JSON isn’t installed. It’s really slow for the history stack. The more content, it gets exponentially slower.

Slide 48

Slide 48

QUERYING ACROSS TABLE COLUMNS

  • AND - JSON VALUES
  • IS A - TWO STEP PROCESS Problem for apps. Requires some mental application logic.

Slide 49

Slide 49

SO WHAT IS
GOOD ABOUT IT? It solved the initial requirement. 
 Queries are really simple - important on over-loaded shared servers.

Slide 50

Slide 50

{ “heading”: “Foo”, “date”: “2011-04-22 10:00:00” } We were storing data like this... Doesn’t take much of a leap to think we can store multiples....

Slide 51

Slide 51

[ { “heading”: “Foo”, “date”: “2011-04-22 10:00:00” }, { “heading”: “Foo”, “date”: “2011-04-22 10:00:00” } ]

Slide 52

Slide 52

[ { “_rev”: 1300447544, “_content”: { “heading”: “Bar”, “date”: “2011-04-22 10:00:00” } }, { “_rev”: 1293968747, “_content”: { “heading”: “Foo”, “date”: “2011-04-22 10:00:00” } } ]

Slide 53

Slide 53

SIMPLE, EFFECTIVE

HISTORY STACK This very simply enabled us to create a history stack, and implement an UNDO feature.

Slide 54

Slide 54

THEORISING IS EASY NOTHING BEATS EXPERIENCE Every solution has its pros and cons. Ultimately you have to pick one and go with it. We anticipated small sites with low content volumes so went with JSON People are building SIMPLE sites with Perch, but not always SMALL. 
 We may have to revisit, but we can migrate architectures with a script. Yay for scripts.

Slide 55

Slide 55

RUNNING PHP EVERYWHERE

IS HARD

Slide 56

Slide 56

WE ' RE USED TO CONTROLLED PLATFORMS We're used to developing on controlled platforms and deploying to controlled platforms We specify what version of PHP. Configure INI options. Install libraries required.

Slide 57

Slide 57

ALL BETS ARE OFF As soon as you give people code to run in their own environment, all bets are o "

  • Web server isn't necessarily Apache
  • We can't use mod_rewrite
  • Users don't even stick to one platform
  • They might start developing on IIS on Windows and deploy to Apache on Linux

Slide 58

Slide 58

  • CHEAP - HOSTING IS CHEAP Some of the big problems are from over-sold cheap hosting. Common to have e.g. PHP sessions enabled, but not working
  • temp folder full, not specified, not writable

Slide 59

Slide 59

WINDOWS IS WEIRD

  • Server variables can't be relied on
  • Permissions are all di " erent
  • DIRECTORY_SEPARATOR

Slide 60

Slide 60

MIGRATING

BETWEEN

FILESYSTEMS

  • MySQL and mysqldump are di " erent depending on filesystem
  • Case sensitivity / preservation is an issue

Slide 61

Slide 61

  • NEVER - MIX CASE IN MYSQL TABLE NAMES Stick to lower case

Slide 62

Slide 62

  • BE - OPINIONATED
  • BUT NOT - DICTATORIAL We said the most di

cult problems are wet ones. Technical problems are hard too.

Slide 63

Slide 63

WYSIWYG

  • IS - EVIL We hate WYSIWYG editors. Decided to ship with Textile, Markdown and MarkItUp! Editor.

Slide 64

Slide 64

Nice compromise - toolbar so you don’t need to remember codes, but no filthy HTML.

Slide 65

Slide 65

But my clients must have an editor like Wor d! People are weak. WEAK! Be strong with your clients!

Slide 66

Slide 66

IT ' S NOT OUR PLACE TO TELL PEOPLE HOW TO WORK If they want to give their client a WYSIWYG editor, so be it. All we can do is give them good, sensible defaults based on our own experience.

  • with services you can impose your will with software you can only give good defaults but have to allow people to do things you consider bad practice "opinionated software"

Slide 67

Slide 67

Slide 68

Slide 68

EDIT IN PLACE

  • IS A - FALSE PROMISE People ask us why we don’t do edit in place. It makes good demo, but we don’t think it scales.

Slide 69

Slide 69

HELP CUSTOMERS

SERVE THEIR

CLIENTS

Slide 70

Slide 70

IDENTIFY YOUR

CUSTOMERS ' PROBLEMS Work out what will make their lives easier, but also make them a hit with their clients.

Slide 71

Slide 71

CONFIDENCE

  • IS - EVERYTHING Getting the end client to use a CMS is a big hurdle for our customers. Clients are confused by things like Wordpress. We designed in features to help. the functionality of software doesn't make it useful on its own - combo of functionality being there ad people being confident to use it. Core di " erence between us and OS projects. They have functionality we work very hard on how it is presented to the user.

Slide 72

Slide 72

EVERY FIELD

  • CAN BE - ANNOTATED

Slide 73

Slide 73

help=”Use the teacher’s initials from the timetable.”

Slide 74

Slide 74

Slide 75

Slide 75

perch:help

<p>Confused? Watch this video:</p> <video>...</video> </perch:help>

Slide 76

Slide 76

Slide 77

Slide 77

Slide 78

Slide 78

DRAFTS PREVIEW UNDO We designed features to help give nervous clients confidence

  • Drafts
  • Preview
  • Undo

Slide 79

Slide 79

  • BE A - MAGICIAN NOT JUST A DEVELOPER Know your own strengths

Slide 80

Slide 80

FUNCTIONALITY -IS NOT - ENOUGH

Slide 81

Slide 81

LEARN TO ACCEPT

WHEN USERS ARE HAVING

TROUBLE

Slide 82

Slide 82

REALLY GREAT DEVELOPERS SOLVE PROBLEMS It’s not just about implementing features. Even if there is a solution if people are not finding or understanding it the solution is still broken.

Slide 83

Slide 83

YOU CAN'T

WIN EVERY USER Know your own strengths

Slide 84

Slide 84

I love the little cms but the one thing I was expecting to get is a license for multiple domain,... if you guys can help with that you will earn a big customer,.. and as of right now I already found 2 more cms just like yours at a lower price but what they take a away is in the interface design,.. (which I could careless about it) but you guys still my number 1 option but if you guys can give me a break on that little part for licensing multiple domains that will be very much appreciated,..

Slide 85

Slide 85

  • NOT -

EVERYONE

WILL GET IT And that’s fine. In fact it’s good. The worst thing to happen is have a product so bland that no one can object to it.

Slide 86

Slide 86

THANK YO U!

Perch is at grabaperch.com Slides: http://lanyrd.com/2011/phpcomcon

On most things, I’ am
@ drewm Know your own strengths

Slide 87

Slide 87

QUESTION S?