Video icon 64
Learning to code? Skill up faster with our practical video courses. Start your free trial today.
Advertisement

Using WordPress as a Web Application Framework

by

Application Frameworks such as Ruby on Rails, CakePHP, CodeIgniter, etc. are common today. If you have ever used them or read about them you might be aware of their features and how they help to speed up web application development. In this article we will discuss the common features found in most of these frameworks and their similarity with WordPress.


What Is a Web Application Framework?

In plain words, an application framework can be called as a reusable set of code libraries or classes. Frameworks allow designers / developers to focus on their software and business logic rather than general details such as user management, database connection, error logging, caching, user friendly link generation, etc. This helps in reducing development time.

Some of the most widely used web application frameworks are Ruby on Rails, CodeIgniter, CakePHP and Zend. These frameworks are built on MVC architecture to separate various aspects of the application.

As the intention of the article is to only compare these frameworks with WordPress, we will now talk only about frameworks built using PHP as that is also what WordPress uses.


Advantages of Using a Web Application Framework

PHP is a widely used programming language. It has received negative criticism in the past but often not because of flaws. PHP has a small learning curve which makes it easier for anyone new in programming to start using it. This has resulted in some users using shortcuts that made their websites/applications less secure.

As every developer has a different style of coding, using a framework helps in some ways to make sure everyone writes in a standard way and follows conventions.

You will find below a list of some of the features these frameworks offer:

  • User Management
  • Template Engine
  • Error Logging
  • Localization
  • Form & Data Validation
  • File Uploading & media management
  • Image manipulation
  • Search-engine Friendly URLs
  • Session Management
  • Trackback, XML-RPC & APIs
  • Ability to extend using hooks & classes or plugins
  • Automated code execution scheduling
  • Caching

WordPress has most of the above capabilities built-in. So the question is why can’t we use WordPress as a framework? As existing users of WordPress we are already aware of the classes and conventions used by WordPress. Using it for our larger projects would allow us to use our existing knowledge to create bigger and more complicated web applications faster using the tool we love to use.


WordPress Features That Make It an Exciting Tool to Be Used as a Framework:

1. Admin & Dashboard

WordPress undoubtedly has one of the best administration back-ends. This may be one of the reasons general users are able to adopt WordPress so quickly. Well organized menu, dashboard widgets and responsive design definitely make WordPress better than any other framework at least in terms of the backend design.

Adding custom menus or creating separate data entry screens for different data sets (thanks to Custom Post Types) is easy to do.

Dashboard allows a quick overview of the website and its contents and you could also create your own Dashboard widgets using a few lines of code such as:

	// Function that output's the contents of the dashboard widget
	function dashboard_widget_function() {
		echo "Hello World, this id my first Dashboard Widget!";
	}
	// Function that beeng used in the action hook
	function add_dashboard_widgets() {
		wp_add_dashboard_widget('dashboard_widget', 'Example Dashboard Widget', 'dashboard_widget_function');
	}
	// Register the new dashboard widget into the 'wp_dashboard_setup' action
	add_action('wp_dashboard_setup', 'add_dashboard_widgets' );
Google Analytics Dashboard Widget

Good examples of these Dashboard widgets would be the Google Analytics Plugin, which gives a quick summary of the analytics for last 30 days in a small dashboard widget.

The WordPress dashboard design can also be changed using CSS to make it white labeled.

2. User Management & Access Control

One most important aspect of any application is user management and access control. WordPress offers a great user management tool along with ability to extend access control for different sections of the application using Roles & Capabilities.

By default, without even a single line of code, WordPress allows different roles such as Administration (with complete control), Editor, Contributor and Subscriber. Using this mechanism it's easier to extend the level of control you give to a user to manage different sections of the website.

3. Templating Engine

Backend features aside, another important part of any project is to create the front facing part of the website. WordPress has one of the easiest templating systems along with detailed documentation and a growing and active community to help you if you ever get stuck.

As it's not based on MVC – Model-View Controllers it's easier for even designers with zero or basic knowledge of PHP to get started with WordPress.

4. Localization

WordPress has built-in capability to support localization. It also offers dynamic class generation so theme developers can make websites easier to access whether the user reads from left to right or right to left.

5. Plugins

As of today WordPress has 20,105 active free plugins in its directory. There are also thousands of high quality plugins for free and a small fee. Plugins extend the default functionality to offer different types of functionalities ranging from caching, sitemap generation, integration with 3rd party services, multi-lingual site content, etc.

6. Caching

Caching is one of the important aspects of any website or web based application. It helps reduce server load and increase speed of a website. WordPress offers a simple caching mechanism that can be activated using just few lines of code and for users who want more control, there are plugins that provide complete controls on the way a website is cached and also offers integration with 3rd party content delivery networks.

7. Search-Engine Friendly URLs

WordPress offers user friendly URL generation using just few clicks and it's well integrated with the rest of the content generation sections.

8. File Uploading & Media Management

WordPress has one of the best uploading and media management functionalities. It does not offer funky image manipulation like Instagram, but it does offer most used features.

With drag and drop uploading, thumbnail generation, connection between a data item such as 'Post' with multiple images, automated gallery creation, WordPress does offer a decent feature list for media management.

9. Hooks, Actions & Filters

WordPress offers many hooks that allow developers to call functions at specific times. These are used to add CSS & JavaScript to the web page's head tags, adding an advertising banner at the end of a post, etc.

10. Error Logging

PHP has a standard error log system which can be activated in WordPress by placing the below lines in your wp-config.php:

	@ini_set('log_errors','On');
	@ini_set('display_errors','Off');
	@ini_set('error_log','/home/example.com/logs/php_error.log');
	/* That's all, stop editing! Happy blogging. */

11. XML-RPC & APIs

WordPress supports XML-RPC which allows remote publishing of data on the website. Currently this is widely used only for remote publishing from a weblog client to a WordPress website, however consider it as something that would allow your desktop applications to communicate with your web based application.

12. Multiple Instances

One of the best features of WordPress has to be WordPress Multisite. It allows you to run multiple instances of WordPress from a single set of core files. This could be used to create either multi-lingual websites, country specific instances of an application or it can be used to also create something as dynamic as Shopify.com with a network of online shops. This is what WordPress.com runs on too.


WordPress was created originally as a blogging application. However for the last few years, talented people in the WordPress community have customized and used it to build not just blogs but portals for newspaper websites, real estate themes, forums, and question & answer sites, as well as many, many more varied websites.


Conclusion

When choosing WordPress you should also be aware of the limitations of WordPress. WordPress is feature rich and hence when using as a base for larger applications, you would have lot of features at your fingertips. However if your requirements demand lot of customization and have interconnection between too many distinct data types than perhaps WordPress would not be the best option.

If you used WordPress as more than a CMS, please share your project with us and tell us what's unique about it, in the comments below.

Advertisement