New: Learn Statamic on Laracasts!

<<< Back to the blog

Statamic 3.3 Released

Jack McDade
Jack McDade March 14th, 2022

Statamic 3.3 is here with a big focus on supercharging your front-end development and template-level functionality.

3.3 includes a brand new Antlers engine packed with powerful new features, streamlined Blade interoperability and tag/modifier helpers, dynamic conditional form fields, new query builder methods, and whole lot more. Feel the excitement and energy by watching this announcement video!

New Features in Statamic 3.3

3.3 is packed full of improvements and enhancements across the entire application, but we’ll cover the big ones here in this blog post. To explore all the smaller, more nitty gritty details, check out the Release Notes. Grab a fresh cup of coffee, there’s a lot.

New Antlers Engine

The new Antlers Engine is a complete and fundamental rewrite that takes a more sophisticated and elegant approach to the business of parsing templates.

The original parser was — essentially — a glorified find and replace machine relying heavily on RegEx. It parsed and evaluated logic as it worked its way in one direction through the template, from top to bottom. This means it couldn’t stop, go backwards, set variables, or in many cases handle nested logic well because something deeper or further down couldn’t stop logic already begun. It also had performance issues as templates got larger. The more characters you push through RegEx, the more processing power it took to process.

The New Antlers Engine now has two stages – first, it parses and builds an Abstract Syntax Tree (AST) from your templates, and then it evaluates and executes the nodes and logic in the tree during runtime (much like a programming language) according to established rules.

This affords Statamic an incredible amount of control. It can go sideways and slantways and longways and backways and squareways and frontways and any other ways that you can think of. Code at the bottom of a template inside several nested tags can bubble up and be available at the top, or in a called partial, and so on.

In turn, this allowed us to build dozens of new features, fix all known Parser-related bugs, and support syntax scenarios that were impossible in the previous “parse and evaluate” flow. Features like…

  • The ability to set variables
  • Syntax errors that reference the exact line, character, and type of error
  • The ability to control parse order through sub-expressions
  • Merge, group, order, and manipulate data without modifiers
  • Perform a robust set of mathematical operations
  • Concatenate, increment, and decrement values
  • More template logic and control flow operators
  • An improved Modifier syntax to provide better readability and type handling
  • A smarter, more forgiving matching engine so more things Just Work™
  • Self-iterating assignments
  • Self-closing tags
  • next and previous loop traversal helpers
  • Run-time caching for huge performance boosts

This new engine is a powerful factory, mad scientist laboratory, and wizarding school all rolled into one. 🏭🧑‍🔬🧙‍♀️

We’re calling it “Experimental”

Because of how fundamental Antlers is to the entire Statamic experience, we’re shipping this new version under an opt-in feature flag until Statamic 3.4 — just in case it affects the behavior or output of one or more of your templates in an unexpected way.

We recommend starting new sites with the new “runtime” engine, but highly suggest testing it for existing sites before just shipping it to production.

Explore all the new Antlers goodies.

Blade Improvements and Helpers

Blade finally gets the attention it has always deserved. And ->value() is obsolete. 🎉

Magic Page Variables

Statamic now injects a $page variable into your Blade views — an Entry class with magic property access. You no longer have to “resolve” your variables with the ->value() method, you can interact with them in a standard object fashion.

<h1>{{ $title }}</h1>

<div class="grid md:grid-cols-3 gap-3">
    @foreach($page->images as $img)
        <img src="{{ $img->url }}" alt="{{ $img->alt }}"/>

Query Builders

If a variable is a query builder (e.g. entries or terms), you can manipulate them with property access:

@foreach ($page->related_posts as $post)
  {{ $post->title }}

Or with the method approach, which has the added benefit of supporting method chaining:

@foreach ($page->related_posts()->where('title', 'like', '%awesome%')->get() as $post)
  {{ $post->title }}

Tag and Modifier Helpers

You can now tap into Statamic’s Tags with the new Statamic::tag() helper.

@foreach (Statamic::tag('collection:blog')->limit(10) as $entry)

In the a similar fashion, you can tap into Statamic’s Modifiers with the new Statamic::modify() helper.

{!! Statamic::modify('hello wild')->slugify()->upper() !!}

Conditional Frontend Form Fields

Your frontend forms can now automatically tap into conditions (like “show when”, “hide when”, “show unless”, and so on) as configured in the control panel. The logic is handled with JavaScript and 3.3. ships with an Alpine.js driver to do it all for you.

Read all about it!

If you you’re using a different JavaScript framework you can write your own JS Driver.

Headless Live Preview

Live Preview got an upgrade and is now configurable to work with headless sites using GraphQL. You can define your Live Preview URL and handle rendering the page in your frontend framework of choice.

This update also allows you to set your own Live Preview targets so you can view how a change to your entry affects the show page, listing page, or any other page you feel is important.

Laravel 9 Support

Statamic 3.3 adds support for Laravel 9 and drops support for Laravel 7. Supporting multiple Laravel versions becomes a big challenge when each version has a different supported PHP version range. It is our position that it is better to stay up to date and progressively drop backwards support for out of date and end-of-life PHP versions than it is to hold the product and ecosystem back trying to avoid the need for server updates.

Everyone is better off running of the the latest, stable, supported version of PHP and Laravel. We wrote about this up and coming changes a few months ago, and you can review the whole major release schedule here.

However, we didn’t want to force anyone to have to jump too far on short notice, so we spent the month of February to bridge the gap between PHP 7.4 and 8.1, Laravel 8 and 9, and all of their respective dependencies.

In short:

  • PHP 7.2 and 7.3 are no longer supported.
  • Laravel 6 and 7 are no longer supported.

If you installed Statamic before October 5th, 2020 and have not upgraded the underlying version of Laravel, you’re most likely running Laravel 7 and will need to make a few extra manual steps as part of the 3.3 update.

Breaking Changes

There are a few breaking changes in 3.3 — all for very good reasons, so be sure to view the upgrade guide to see if they affect you (hint: they probably don’t).

The Rest

Check out the Release Notes to see the full list of enhancements and fixes in 3.3, and take a peek at the the roadmap to see what’s coming next!

A new feed approaches!