rapidly prototyping web applications using backpress

20
Rapidly Prototyping Web Applications Using BackPress WordCamp Seattle April 16,2011

Upload: nathaniel-taintor

Post on 05-Jul-2015

2.959 views

Category:

Technology


4 download

DESCRIPTION

From my talk at WordCamp Seattle 2011:Most people who work with WordPress every day have at best a passing familiarity with what BackPress is. And for good reason – its a very unfinished project, with very few real-world examples and very scarce documentation. At its heart, though, BackPress is (was) a very ambitious project, and still can be valuable to developers who learned to code hacking on WordPress. The same functionality and structure that makes WordPress so easy and pleasant to work on can be harnessed to just about any end you can imagine. I’ll try to explain when and where BackPress might be a good choice to use on a project, and what to look at if you’re thinking about getting started in it.

TRANSCRIPT

Page 1: Rapidly prototyping web applications using BackPress

Rapidly Prototyping Web Applications Using BackPress

WordCamp Seattle

April 16,2011

Page 2: Rapidly prototyping web applications using BackPress

What is BackPress?http://backpress.org

BackPress is a PHP library of core functionality for web applications. It grew out of the immensely popular WordPress project, and is also the core of the bbPress and GlotPress sister-projects.

“”

Page 3: Rapidly prototyping web applications using BackPress

Basically (for the purposes of this introduction)...

BackPress is all the goodies in WordPress that handle user authentication, sanitize & escape data, and format text, etc. —

without all the overhead.

• Logging,

• User Roles and Capabilities (Permission systems),

• Database connections (across multiple servers and multiple datacenters),

• HTTP Transactions,

• XML-RPC Server and Client,

• Object caching,

• Formatting,

• XSS and SQL injection protection, including a variety of powerful escaping functions,

• Taxonomies and

• Options management

(Copied directly from the front page of backpress.org)

Page 4: Rapidly prototyping web applications using BackPress

If you’ve developed for WordPress, you’ve probably used one or more of

these life-saving features:

(if not, most likely #urdoingitwrong!)

• $WPDB class (EZ-SQL plus prepare statements)

• $current_user, is_user_logged_in()… etc.

• HTTP API - wp_remote_request() etc.

• wp_cron() – pseudo-cron functionality

• sanitize_text_field(), esc_html(), wp_kses()…

• wpautop(), make_clickable(), is_email()...

Page 5: Rapidly prototyping web applications using BackPress

“But most of these functions aren’t unique to WordPress… they were adapted from

other sources, they’re in other packages”

• True, but... WordPress core has spent years including and refining them from a best practices perspective.

• True, but... I’m talking from the persective of someone who learned to code writing WP themes and plugins. I already know the WP syntax; why learn another framework just to get a project off the ground fast?

• True, but... Most projects will end up with a blog or a CMS at some point down the road. If you’re going to use WordPress in your project anyway, why not start your project with a data structure and a syntax that’s compatable with WordPress?

Page 6: Rapidly prototyping web applications using BackPress

And as importantly as any of these reasons, from a subjective perspective:

•WordPress has its own well-defined coding style “The source code is the documentation”: even if there’s no documention available on a BackPress class or function, its probably coded in a way that’s easy to read if you’re used to working with WordPress.

•Answers to WordPress questions are everywhere. If you’re hung up on the best way to handle a specific problem, chances are you can get answers with a simple search.

Page 7: Rapidly prototyping web applications using BackPress

What is rapid prototyping?

• Quick proof of concept - demonstrating and validating your idea

• Being “first to market”, at least with a soft launch

• Getting your first 10/100 users

• Very early-stage user feedback to guide the development of your project

• Possibly “disposable” framework, mocking up the functionality you may rewrite in your finished product

Page 8: Rapidly prototyping web applications using BackPress

Concerns of rapid prototyping:

• Making it work

• Usability

• Basic security

Don’t have your

brand-new idea shot

down by this guy!

Page 9: Rapidly prototyping web applications using BackPress

Concerns of rapid prototyping:

Not your concern (yet):

• Making it work

• Usability

• Basic security

• Making it scale

• The business plan

• Elegant code / design

Page 10: Rapidly prototyping web applications using BackPress

So, you decide you want to prototype your web app.

What are your options?

Page 11: Rapidly prototyping web applications using BackPress

Library vs Framework

• BackPress is technically a library, not a framework.

• Nothing happens by default.

• You have to include the parts you need in order to take advantage of them.

Page 12: Rapidly prototyping web applications using BackPress

Django:startproject <projectname>

Rails:rails <projectname>

CakePHP:cake bake

symfony:generate:project <projectname>

Compare starting a project in these frameworks:

Typically web frameworks have a simple command-line tool to create the bare minimum of a project. You will still need to include or import specific modules that you need for functionality in your app, but out of the box, the framework provides the basic structure for separating model and view, and displaying an initial page.

In contrast, a library like BackPress is essentially no more than a collection of core files. It does nothing on its own. You have to decide which files you need to include, in which order to require them, and structure your application yourself.

Page 13: Rapidly prototyping web applications using BackPress

With starting a BackPress project:

Get the current BackPress files; add to a directory in your project root:svn co http://svn.automattic.com/backpress/trunk/includes \ backpress

Most of the files were ported over 2009-2010. Mostly synched with WP3.0, not 3.1 yet.

(maybe with more community interest, the project will be revitalized?)

Page 14: Rapidly prototyping web applications using BackPress

With starting a BackPress project:

Get the current BackPress files; add to a directory in your project root:svn co http://svn.automattic.com/backpress/trunk/includes \ backpress

Make sure to include all the files you’ll need in your project. I usually include something like this in a shared header file:<?php require_once dirname( __FILE__ ) . ‘/backpress/functions.core.php’; require_once dirname( __FILE__ ) . ‘/backpress/class.wp-error.php’; require_once dirname( __FILE__ ) . ‘/backpress/class.bpdb.php’; require_once dirname( __FILE__ ) . ‘/backpress/functions.formatting.php’; require_once dirname( __FILE__ ) . ‘/backpress/functions.kses.php’; require_once dirname( __FILE__ ) . ‘/backpress/class.wp-pass.php’; require_once dirname( __FILE__ ) . ‘/backpress/class.bp-user.php’; require_once dirname( __FILE__ ) . ‘/backpress/class.wp-auth.php’; require_once dirname( __FILE__ ) . ‘/backpress/class.wp-http.php’; //plusanyotherfilesyouneedforyourspecificapp?>

If you’re not sure what files you’ll need, might as well err on the side of caution to begin with. Take a look at any of the public projects written on BackPress for a sense of how to structure your init files.

Page 15: Rapidly prototyping web applications using BackPress

With starting a BackPress project:

Get the current BackPress files; add to a directory in your project root:svn co http://svn.automattic.com/backpress/trunk/includes \ backpress

Make sure to include all the files you’ll need in your project. I usually include something like this in a shared header file:<?php require_once dirname( __FILE__ ) . ‘/backpress/functions.core.php’; require_once dirname( __FILE__ ) . ‘/backpress/class.wp-error.php’; require_once dirname( __FILE__ ) . ‘/backpress/class.bpdb.php’; require_once dirname( __FILE__ ) . ‘/backpress/functions.formatting.php’; require_once dirname( __FILE__ ) . ‘/backpress/functions.kses.php’; require_once dirname( __FILE__ ) . ‘/backpress/class.wp-pass.php’; require_once dirname( __FILE__ ) . ‘/backpress/class.bp-user.php’; require_once dirname( __FILE__ ) . ‘/backpress/class.wp-auth.php’; require_once dirname( __FILE__ ) . ‘/backpress/class.wp-http.php’; //plusanyotherfilesyouneedforyourspecificapp?>

Initiate your database connection, check user authentication if necessary, process the request and include template files, etc.

Page 16: Rapidly prototyping web applications using BackPress

With starting a BackPress project:

Get the current BackPress files; add to a directory in your project root:svn co http://svn.automattic.com/backpress/trunk/includes \ backpress

Make sure to include all the files you’ll need in your project. I usually include something like this in a shared header file:<?php require_once dirname( __FILE__ ) . ‘/backpress/functions.core.php’; require_once dirname( __FILE__ ) . ‘/backpress/class.wp-error.php’; require_once dirname( __FILE__ ) . ‘/backpress/class.bpdb.php’; require_once dirname( __FILE__ ) . ‘/backpress/functions.formatting.php’; require_once dirname( __FILE__ ) . ‘/backpress/functions.kses.php’; require_once dirname( __FILE__ ) . ‘/backpress/class.wp-pass.php’; require_once dirname( __FILE__ ) . ‘/backpress/class.bp-user.php’; require_once dirname( __FILE__ ) . ‘/backpress/class.wp-auth.php’; require_once dirname( __FILE__ ) . ‘/backpress/class.wp-http.php’; //plusanyotherfilesyouneedforyourspecificapp?>

Initiate your database connection, check user authentication if necessary, process the request and include template files, etc.

Finally, let your application logic do whatever its supposed to do.

Page 17: Rapidly prototyping web applications using BackPress

Limitations of BackPress:(once you get it operational, that is)

• Lack of MVC (model/view/controller separation)

• Lack of dashboard, admin, analytics, etc.

• Code occasionally buggy

• No clear structure for how various parts should be integrated

• Codebase not being actively maintained

• Support/developer lists & forums very quiet

But really, its WordPress without the “word”... how difficult can it be?

Page 18: Rapidly prototyping web applications using BackPress

Interlude: Some public projects using BackPress

(forum structure, now integrated into BuddyPress)

(collaborative translation tool)

SupportPress (support ticketing system)

and some others being developed publicly:

GeoPress (self-hosted geo-tagging/check-in site engine)

All of these are available on svn and/or github. If you want to start hacking BackPress, any of these projects are a good place to start.

Page 19: Rapidly prototyping web applications using BackPress

Wordpress BibleAaron BrazellWiley, 2010

“BackPress, Your New Best Friend”

Beau Lebenshttp://dentedreality.com.au/2009/12/backpress-your-new-best-friend/

Some more resources to get started:

Page 20: Rapidly prototyping web applications using BackPress

Thanks, and Happy Hacking!

Nathaniel Taintorhttp://goldenapplesdesign.com@GoldenApples