My Ultimate Wordpress Setup

Aldi Daswanto
3 min readJul 9, 2016

Coming from Wordpress background, recently I was involved in some laravel — based projects and I’ve been introduced to a set of features / tools that gave me a new level of fun while developing an PHP based project :

  1. Composer (dependency manager),
  2. Better separation of concern (MVC pattern),
  3. Easy to configure Routing system,
  4. No-nonsense templating engine,
  5. Better project folder structure,
  6. Better password encryption,
  7. Strip all environment’s configuration settings from a php file, and put them all in an .env file,
  8. Elixir for managing front-end tasks

By the way, for some of my projects, Wordpress is still my CMS of choice. It’s easy to setup, tons of plugins are available to download to extend its basic functionality, very easy to get support from community, we can easily purchase a theme, even a custom theme is relatively fast to develop, and ready to use — easy to use admin interface (The Dashboard).

But by using wordpress — developing my own custom theme, my code is very easily turned into a messed up PHP code. I usually end up mixing altogether the loop and the HTML. A lot of repetitive tasks must be done to construct the intended page layout. Furthermore, wordpress is still using unsecure md5 encryption for user’s password, and in this point, I miss some of laravel’s features.

So after did some research, I found some interesting tools that will help me maintain and develop wordpress-based project easier, more developer friendly, and in a more fun way.

Bedrock

This is an alternative wordpress boilerplate. Came from roots.io family, bedrock has interesting features such as :

  • Using composer for managing project’s dependencies, even we can manage our project’s plugin / theme using composer via wordpress packagist
  • Better project folder structure. It put wordpress’ core files into separate folder, and manage project’s dependencies (themes, plugins, etc.) into another folder — app folder
  • Separate configuration file from wp-config.php file, and store all project’s configuration in an .env file. We can easily switch environment — development, staging, production using configuration stored in this .env file.
  • Replace md5 encryption with bcrypt for better security

Sage

Sage is another member from roots.io family. It’s a theme framework, and it came with modern workflow in mind. In the time of writing this article, Sage using :

  • Bootstrap (SASS) as default CSS framework
  • Gulp to automate frontend tasks such as combine and minified javascript files, compile and minified SASS files, images compression
  • Bower to manage front-end dependencies (front-end package manager)
  • Using BrowserSync, to live-reload our theme while developing. BrowserSync will synchronize all click, scroll, page refresh, etc between browsers while testing

Timber

Timber is a plugin that integrate twig templating engine into wordpress. FYI, Twig is a templating engine originating from Symfony PHP framework. It’s like Blade to Laravel.

Combining Twig templating engine with Sage, we can easily separate theme’s logic with its HTML layout. We’ll have cleaner, more maintainable code. Timber came with some helpful tools such us :

  • TimberPost : manage our post object and make it available from the twig template. TimberPost make it easier to work with post’s custom field, and post’s featured image
  • TimberImage : very helpful when we have to deal with image resizing in wordpress
  • Routing : we can declare a custom route like we do in laravel
  • TimberMenu : expose the menu object into twig template

Bonus : WP-Redis

To make our Wordpress site run faster, a better caching is a must. Using WP-Redis, we can cache our wordpress query result into Redis (a high performace in memory storage).

So once a query result cached into redis, wordpress doesn’t need to re-query it through MySQL. And call the query result directly into Redis is much much faster.

Conclusion

Wordpress is still my favourite CMS of choice. As an open source project, we can freely modify Wordpress to meet our needs. It’s 2016, and lots of modern development tools has been available to be used. And for sure, we can improve our daily development workflow using these tools.

Have any personal preferences for building your version of ultimate Wordpress setup? Please feel free to write them up in the comment section below.

--

--