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.
Rapidly prototyping web applications using BackPress
1. Rapidly Prototyping
Web Applications
Using BackPress
WordCamp Seattle
April 16,2011
2. 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.
3. 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, • Object caching,
• User Roles and Capabilities • Formatting,
(Permission systems), • XSS and SQL injection
• Database connections protection, including a
(across multiple servers and variety of powerful escaping
multiple datacenters), functions,
• HTTP Transactions, • Taxonomies and
• XML-RPC Server and Client, • Options management
(Copied directly from the
front page of backpress.org)
4. If you’ve developed for WordPress,
you’ve probably used one or more of
these life-saving features:
• $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()...
(if not, most likely #urdoingitwrong!)
5. “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?
6. 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.
7. 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
8. Concerns of rapid prototyping:
• Making it work
• Usability
• Basic security
Don’t have your
brand-new idea shot
down by this guy!
9. Concerns of rapid prototyping:
• Making it work
• Usability
• Basic security
Not your concern (yet):
• Making it scale
• The business plan
• Elegant code / design
10. So, you decide you want to prototype your web app.
What are your options?
11. 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.
12. Compare starting a project in these frameworks:
Django: CakePHP:
startproject <projectname> cake bake
Rails: symfony:
rails <projectname> generate:project <projectname>
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.
13. 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?)
14. 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’;
// plus any other files you need for your specific app ?>
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.
15. 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’;
// plus any other files you need for your specific app ?>
Initiate your database connection, check user authentication if
necessary, process the request and include template files, etc.
16. 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’;
// plus any other files you need for your specific app ?>
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.
17. 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?
18. 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.
19. Some more resources to get started:
“BackPress, Your New Best Friend” Wordpress Bible
Beau Lebens Aaron Brazell
http://dentedreality.com.au/2009/12/backpress- Wiley, 2010
your-new-best-friend/
20. Thanks, and
Happy Hacking!
Nathaniel Taintor
http://goldenapplesdesign.com
@GoldenApples