Why I’m So Excited About Craft (and why you should be)

28 May 2013

In the past couple of weeks I’ve spent more and more time playing with Craft, the new CMS by Pixel & Tonic. When I say playing with, I mean working with, but since it is proving to be such a joy to use, I feel that playing” is a more appropriate word.

Craft publish

What P&T have done is built a Content Management System in the truest sense, from the ground up. What I mean by this is that Craft was built to do one thing and do it well, and that is to manage content. Feel free to take a deep breath of fresh air.

In recent years the term CMS has come to mean a web publishing system rather than a system for simply managing content. Wordpress for example, originally a blogging platform, has been extended into a CMS, that is a web publishing system that can be extended with plugins. Similarly, ExpressionEngine matured from pMachine, blogging software, into a CMS that can handle multiple channels of content and that can be extended with various types of add-ons.

As a user of ExpressionEngine I love how extensible, flexible and powerful it is, yet the notion of it being a platform is not yet a reality in my mind. In my recent talk at EEUK I made the following statement in my final slide:

ExpressionEngine as a Platform – requires a paradigm shift in the level of freedom and control we have over our content”

This was in the context of a front-end API that I had developed and demoed in the presentation, but it still holds true in the larger context of CMS’s. What I have been wishing for – the holy grail of CMS’s – is one that doesn’t put any limitations or rules on the type of content that I can create and what I can do with it.

Now I’m not saying that Craft is the answer to my dreams, but it is pretty damn close. If you have not yet tried out Craft yet then I’ll forgive you, but version 1.0 will be released in less than a week, and you would be a fool to dismiss this as insignificant.

Bold claims should be backed up, so here are the three reasons that I’ve become slightly obsessed with Craft.

1. Twig #

Craft uses the Twig templating language (from the makers of Symfony), which compiles down to plain PHP code. Besides making things fast, it provides a few killer features:

Parsing Engine #

There is no such thing as parse order!! Since Twig has a real parsing engine, it simply compiles templates into PHP and then executes them. Case closed.

Variables, Filters and Functions #

Twig allows you to set and use variables in a similar way to PHP:

My name is {{ user.name }}

Filters allow you to modify variables and provide a huge amount of functionality. They pretty much replace the need for plugins in ExpressionEngine. Remember that time you just wanted to strip html from a string and rather than just add a line of PHP you code to your template you went and installed a plugin? Well with Twig you could just do this:

{{ body|striptags }}

There are lots of extremely useful filters for doing all sorts of basic, as well as complex, manipulations. Some examples of useful filters are as follows:

{{ 'the end'|capitalize }}                  : outputs "The end"

{{ entry.postDate|date('m/d/Y') }}       : outputs a date in the format "06/15/2013"

{{ 'Desdemona'|first }}                     : outputs “D” 

{{ ['A', 'C', 'E']|join('.') }}             : outputs "A.C.E"

{{ cities|length }}                         : outputs the number of items in cities 

{{ 2000.7|number_format(2, '.', ',') }}     : ouputs "2,000.70"

{{ 'Good cat!'|replace({'cat': 'dog'}) }}   : outputs "Good dog!"

{{ 'Stop.'|trim('.') }}                     : outputs "Stop"

{{ 'Jump'|upper }}                          : outputs "JUMP"

Functions allow you to generate content, just like PHP functions, and the best thing is that you can create your own filters and functions with a Twig extension.

{{ range(2010, 2013) }}                     : outputs "[2010, 2011, 2012, 2013]"

Control Structure #

Twig also has built in conditional statements (if/​elseif/​else) and for loops, so you have an incredible amount of flexibility and control over your templates.

{% if users|length > 0 %} 
    {% for user in users %}
        {{ user.username }}
    {% endfor %}
{% endif %}

Template Inheritance #

One of the coolest features of Twig is template inheritance. This allows you to build a base skeleton template that contains all the common elements of your site and defines blocks that child templates can override. I won’t go into it in detail here but it makes templating a joy.

There is so much more that Twig can do and you can find it in the excellent docs for template designers. Oh yeah, and one more thing, the entire Craft control panel is responsive and is built with Twig templates!!

2. Yii #

Yii is the PHP framework that Craft is built on. Yii does a few things really well which is what makes it exciting as a framework: proper MVC, ActiveRecord, built-in internationalisation and localisation, lazy loading.

MVC and ActiveRecord make developing with Yii a pleasure. Lazy loading means that class files are not loaded until the class is used for the first time, meaning that you get a significant performance boost (at least these stats seem to indicate so).

Performance

The built-in internationalisation and localisation is of great significance when building a multi-lingual site. The reason ExpressionEngine does not have (and probably could never have) a silver bullet multi-lingual add-on is that there so much possible complexity involved in multi-lingual sites (languages, time zones, date formats, number formats, etc.). Since Yii can handle these complexities natively, Craft is perfectly suited to multi-lingual sites.

I won’t go into too much more detail on Yii here, you can read up on it on their about page.

3. Pixel & Tonic #

There is no denying that Pixel & Tonic have created some of the most popular add-ons for ExpressionEngine with a level of quality that is highly impressive. The fact that they are behind Craft gives me a great amount of confidence in the product and their vision for it. Brandon Kelly has proved himself to be a prodigy in his own right and has built up a very respectable team.

There are some other important factors at play here though:

  • Craft has gone through 64 release to date, all wonderfully documented, and the developers are adding features and fixing bugs at a rate that is unprecedented. Releases

  • There is already a community of over 600 people based around Craft and these other numbers are just as impressive.

  • The forecast feature list is actually public!! (I probably shouldn’t be as excited as I am about this but the feeling of being involved in where a product I care about is going is mightily refreshing) Feature List

  • Developers, myself included, have already started deploying live sites and developing plugins for Craft. The plugin architecture has been thought out and implemented exceedingly well!

  • Updating Craft can be done with a single click (yes, you read that correctly)

  • It is no big secret that there will be a plugin marketplace in which you can buy and install plugins from inside the Craft control panel, hopefully launching soon.

It may come across that I only have praise for Craft, and well, I do. In saying that, Craft has a long way to go before it will be able to compete with the big boys, but once the plugin marketplace is up and running and reaches critical mass it will most definitely be a major contender in the CMS market.

Craft will launch on the 4th of June 2013. In less than a week. Now that is something to get excited about!!