Using WordPress for Web Application Development: An Introduction
Now more than ever, developers and designers are beginning to see the potential for using WordPress as a way to build web applications.
By that, I mean that the community is beginning to see that WordPress can be used for more than blogging and more than just content management: Instead, it can be used to power database-backed applications that run within the context of the web browser.
And why not, right? When you take a step back and look at all of the things that WordPress offers, you have a pretty strong case for just how powerful WordPress really is.
For example, WordPress ships with:
- A database with a flexible data schema
- A core application layer with numerous hooks of which we can take advantage
- The ability to handle client-side, server-side, user-facing, and administrator-facing tasks
In fact, Matt Mullenweg has been quoted as saying:
When you think about it, we're kind of building a web operating system.
But that doesn't mean that WordPress is the right fit for everything. After all, how many frameworks, foundations, libraries, tools, and so on do we have for helping us build web applications?
In this series, we're going to take a look at exactly what WordPress offers as it relates to building web applications, the difference in an application framework and a foundation, the features that lend themselves to building full-stack applications with WordPress, as well as how WordPress is not a silver bullet for writing software for the web.
Of Frameworks and Foundations
One of the most common misnomers that I hear applied to WordPress is how it is a framework for web applications. By the very definition of "framework" and by the very definition of what WordPress is, it's not a framework - it's a foundation.
What's a Framework?
As Wikipedia defines it, a software framework is the following:
In computer programming, a software framework is an abstraction in which software providing generic functionality can be selectively changed by additional user-written code, thus providing application-specific software. A software framework is a universal, reusable software platform to develop applications, products and solutions. Software frameworks include support programs, compilers, code libraries, tool sets, and application programming interfaces (APIs) that bring together all the different components to enable development of a project or solution.
To put it simply, a framework consists of a set of conventions - such as where files should go - as well as libraries and tools - such as a database abstraction layer - that allow us to easily begin working on an application.
With a framework, you can focus on a specific problem domain that's unique to the solution that you're trying to build. For example, let's say that you're going to be building some simple type of account software that's responsible for tracking deposits, withdrawals, and keeping track of available (or not-so-available cash).
In this scenario, you'll have a database that's unique to this problem, a database abstraction layer that makes it easy for you to read and write data to the defined schema, and a set of conventions for organization of the presentation code (that is, what's responsible for displaying data to the user and with which the user interacts), and for organization of the application code which sits between the presentation code and the database code that encapsulates any business logic unique to the problem.
You see, a framework provides the means by which an application can be built from the ground up. It helps facilitate the creation of an application from the database schema up to the front-end.
Then What's a Foundation?
The truth is, that sounds a lot like what WordPress offers, doesn't it?
But the thing is, WordPress provides a predefined database, a predefined set of application code (and, thus, APIs), as well as ways to render data using template files.
Simply put, WordPress is an application that provides a set of APIs and conventions that we can use to build applications on top of. It already provides a schema, core data logic, some business logic, and presentation strategies out-of-the-box.
Whereas a framework allows you to actually build an application, a foundation allows you to extend an application.
And that's what we end up doing with WordPress: We take advantage of the predefined database, the available APIs, and the template system for displaying data to build solutions using an application that's already defined.
In short, software can be built on frameworks, software can extend foundations.
A bit confused?
As we did in the last section, we took a look at how you would go about building a very simple piece of accounting software. Recall that it required that we define a database schema, write code for reading and writing to the database, write code for handling the business logic, build templates for rendering data and interacting with the user, and then placing the files wherever they are required to fit with the conventions of the framework.
With WordPress, it's entirely possible to use the existing database system to handle all of this. You can use APIs for sanitizing and validating data, you can use templates to render the information, and you can use hooks to implement custom functionality for interacting with the user.
So What's the Difference?
So yes, although the same type of software can be built on a framework or a foundation, there are differences between frameworks and foundations, and I think it's very important to understand the difference in both before diving any deeper into the series.
Simply put, frameworks are not applications, foundations are applications.
Just because a web application can be built using WordPress does not make it a framework. It's a foundation. It's an application unto itself that can be extended into further applications.
Things such as Rails, Laravel, CakePHP, Zend, and CodeIgnitor are frameworks because when you download, install, and set them up, they can't actually do anything until you give them enough code to do so.
Foundations aren't like that. They can already do things whether or not you've written a line of code yourself.
What's Up Next?
As mentioned, throughout this series, we're going to be taking a look at the foundation WordPress provides for writing web applications.
Of course, there is no silver bullet when it comes to writing a web application. The purpose of the series isn't to convince anyone as to why WordPress should be used over any other framework or foundation. Instead, the purpose is simply to show what you can do with WordPress and why it may be a viable alternative for your next project.
Although there won't be a lot of technical material - such as code - there will be plenty of examples of what APIs WordPress has available, how they can be used, and what they can be used for when it comes to writing an application.
Starting in the next article, we're going to see what it means to shift our conceptual model of thinking about building web applications from patterns and frameworks to something like WordPress.