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 play­ing with Craft, the new CMS by Pixel & Ton­ic. When I say play­ing with, I mean work­ing with, but since it is prov­ing to be such a joy to use, I feel that play­ing” is a more appro­pri­ate word.

Craft publish

What P&T have done is built a Con­tent Man­age­ment Sys­tem 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 man­age con­tent. Feel free to take a deep breath of fresh air.

In recent years the term CMS has come to mean a web pub­lish­ing sys­tem rather than a sys­tem for simply man­aging con­tent. Word­press for example, ori­gin­ally a blog­ging plat­form, has been exten­ded into a CMS, that is a web pub­lish­ing sys­tem that can be exten­ded with plu­gins. Sim­il­arly, Expres­sion­En­gine matured from pMa­chine, blog­ging soft­ware, into a CMS that can handle mul­tiple chan­nels of con­tent and that can be exten­ded with vari­ous types of add-ons.

As a devoted user of Expres­sion­En­gine I love how extens­ible, flex­ible and power­ful it is, yet the notion of it being a plat­form is not yet a real­ity in my mind. In my recent talk at EEUK I made the fol­low­ing state­ment in my final slide:

Expres­sion­En­gine as a Plat­form – requires a paradigm shift in the level of free­dom and con­trol we have over our content”

This was in the con­text of a front-end API that I had developed and demoed in the present­a­tion, but it still holds true in the lar­ger con­text of CMS’s. What I have been wish­ing for – the holy grail of CMS’s – is one that doesn’t put any lim­it­a­tions or rules on the type of con­tent that I can cre­ate and what I can do with it.

Now I’m not say­ing 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 for­give you, but ver­sion 1.0 will be released in less than a week, and you would be a fool to dis­miss this as insignificant.

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

1. Twig #

Craft uses the Twig tem­plat­ing lan­guage (from the makers of Sym­fony), which com­piles down to plain PHP code. Besides mak­ing things fast, it provides a few killer features:

Pars­ing Engine #

There is no such thing as parse order!! Since Twig has a real pars­ing engine, it simply com­piles tem­plates into PHP and then executes them. Case closed.

Vari­ables, Fil­ters and Func­tions #

Twig allows you to set and use vari­ables in a sim­il­ar way to PHP:

My name is {{ user.name }}

Fil­ters allow you to modi­fy vari­ables and provide a huge amount of func­tion­al­ity. They pretty much replace the need for plu­gins in Expres­sion­En­gine. Remem­ber that time you just wanted to strip html from a string and rather than just add a line of PHP you code to your tem­plate you went and installed a plu­gin? Well with Twig you could just do this:

{{ body|striptags }}

There are lots of extremely use­ful fil­ters for doing all sorts of basic, as well as com­plex, manip­u­la­tions. Some examples of use­ful fil­ters 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"

Func­tions allow you to gen­er­ate con­tent, just like PHP func­tions, and the best thing is that you can cre­ate your own fil­ters and func­tions with a Twig extension.

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

Con­trol Struc­ture #

Twig also has built in con­di­tion­al state­ments (if/​elseif/​else) and for loops, so you have an incred­ible amount of flex­ib­il­ity and con­trol over your templates.

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

Tem­plate Inher­it­ance #

One of the coolest fea­tures of Twig is tem­plate inher­it­ance. This allows you to build a base skel­et­on tem­plate that con­tains all the com­mon ele­ments of your site and defines blocks that child tem­plates can over­ride. I won’t go into it in detail here but it makes tem­plat­ing a joy.

There is so much more that Twig can do and you can find it in the excel­lent docs for tem­plate design­ers. Oh yeah, and one more thing, the entire Craft con­trol pan­el is respons­ive and is built with Twig templates!!

2. Yii #

Yii is the PHP frame­work that Craft is built on. Yii does a few things really well which is what makes it excit­ing as a frame­work: prop­er MVC, Act­iveRecord, built-in inter­na­tion­al­isa­tion and loc­al­isa­tion, lazy loading.

MVC and Act­iveRecord make devel­op­ing with Yii a pleas­ure. Lazy load­ing means that class files are not loaded until the class is used for the first time, mean­ing that you get a sig­ni­fic­ant per­form­ance boost (at least these stats seem to indic­ate so).

Performance

The built-in inter­na­tion­al­isa­tion and loc­al­isa­tion is of great sig­ni­fic­ance when build­ing a multi-lin­gual site. The reas­on Expres­sion­En­gine does not have (and prob­ably could nev­er have) a sil­ver bul­let multi-lin­gual add-on is that there so much pos­sible com­plex­ity involved in multi-lin­gual sites (lan­guages, time zones, date formats, num­ber formats, etc.). Since Yii can handle these com­plex­it­ies nat­ively, Craft is per­fectly suited to multi-lin­gual 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 & Ton­ic #

There is no deny­ing that Pixel & Ton­ic have cre­ated some of the most pop­u­lar add-ons for Expres­sion­En­gine with a level of qual­ity that is highly impress­ive. The fact that they are behind Craft gives me a great amount of con­fid­ence in the product and their vis­ion for it. Brandon Kelly has proved him­self to be a prodigy in his own right and has built up a very respect­able team.

There are some oth­er import­ant factors at play here though:

  • Craft has gone through 64 release to date, all won­der­fully doc­u­mented, and the developers are adding fea­tures and fix­ing bugs at a rate that is unprecedented. Releases

  • There is already a com­munity of over 600 people based around Craft and these oth­er num­bers are just as impressive.

  • The fore­cast fea­ture list is actu­ally pub­lic!! (I prob­ably shouldn’t be as excited as I am about this but the feel­ing of being involved in where a product I care about is going is migh­tily refreshing) Feature List

  • Developers, myself included, have already star­ted deploy­ing live sites and devel­op­ing plu­gins for Craft. The plu­gin archi­tec­ture has been thought out and imple­men­ted exceed­ingly well!

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

  • It is no big secret that there will be a plu­gin mar­ket­place in which you can buy and install plu­gins from inside the Craft con­trol pan­el, hope­fully launch­ing soon.

It may come across that I only have praise for Craft, and well, I do. In say­ing that, Craft has a long way to go before it will be able to com­pete with the big boys, but once the plu­gin mar­ket­place is up and run­ning and reaches crit­ic­al mass it will most def­in­itely be a major con­tender in the CMS market.

Craft will launch on the 4th of June. In less than a week. Now that’s some­thing to get excited about!!