Blog / Why choose Bolt CMS? A developer’s perspective

We’d had our eyes on Bolt for quite a while. In a world of Drupal and WordPress, Bolt stood out as a well-architected PHP application built with a modern software development outlook.  It uses YAML for configuration files, Composer for extensions, Twig for templates, and Silex for routing.

Bolt goes out of its way to use familiar, modern conventions to make everything work. If you’ve done backend or frontend development recently, you may already be familiar with a lot of its core technologies.

YAML for configuration

That’s right, every setting in Bolt is stored on-disk in a YAML configuration file. YAML is great because it’s extremely flexible, works with tons of existing tools, and has a concise, readable format. Having config files on disk means you can edit them with your text editor, automatically validate them, and store them in source control.

Additionally, YML is easily machine-editable, so many of these files can be edited using the bolt admin GUI.

Here’s a rundown of the main configuration files, in order of how often you’ll use them:

  • config.yml – main config data
  • config_local.yml – have something that you don’t want to be in source control, or maybe you have settings that need to be different between your local copy and your live site? Any settings in this file will overwrite those specified in config.yml. It’s perfect for stuff like database credentials or SMTP settings
  • contenttypes.yml – this thing is one of Bolt’s killer features – more on it later. basically, It lets you describe SQL tables that your site will use. Next time you visit the admin area, changes will be detected and Bolt will set those tables up for you. They show up in the admin area automatically.
  • menu.yml – gosh, this thing is awesome too. Using menu.yml, you can describe the tree structure of your site’s navigation. Or multiple navigations. Later on I’ll discuss how we set up the main nav, footer, and four other menus using menu.yml. Besides being hand-editable, there’s also an awesome drag-and-drop tool which admins can use to edit menus in the admin GUI.
  • routing.yml – use this to fully customize how your site’s URLs are routed. It comes in handy if you want to get hands-on with your site’s URL patterns
  • taxonomy.yml – use this to set up categories, tags, or other custom organization systems. Taxonomies you create here will automatically be selectable when admins edit an item of the relevant content type, like tags for blogs as an example.
  • permissions.yml – configure permissions for your various user levels

Bolt uses Composer to manage software

Composer is a large part of PHP’s renaissance in the last few years. It’s a package manager that makes it easy for a piece of software to state exactly what its dependencies are, and then install those dependencies.

Bolt makes robust use of Composer in 3 main ways.

Bolt uses Composer to manage its own dependencies

Bolt’s dependencies are the external software that it uses to get more work done. This includes widely-loved, well-tested workhorses like Twig, Doctrine, utilphp, and Symfony components.

Bolt uses Composer for extension management

Bolt has a flexible and modular extension system. Extensions (plugins) make it easy for anyone to write software that adds new features to Bolt. Does your site need a special widget or form? A custom extension is the right way to do it. Or, you can download one of the many extensions that have already been written, like BoltForms for example. If you do write a custom extension, you can keep it on the local filesystem, or release it publicly via extensions.bolt.cm.

Extensions can be managed via the admin GUI, or the command line. In any case, a simple composer.json file lies at the core of Bolt’s extension management.

You can use Composer to update Bolt itself

Rather than installing Bolt via a downloaded zip file, you can choose to install it as just another composer dependency, then load it via a brief bootstrap file. In this case, you can easily update bolt via your normal composer workflow.

Bolt uses twig for templates

Twig is a widely used, well documented, and versatile templating system used in many PHP projects. It’s Bolt’s default templating system, and it was very fun to work with.

Bolt’s Twig helper functions

Bolt conveniently provides some helper functions for fetching content from within your Twig templates. Yes, that probably crosses the line of letting templates execute code, but in this case, it’s very brief bits of code like this:

{% set articles = record.related('kbarticles') %}

Again, it’s a bit icky to put so much logic in your templates, but I have trouble disliking something so straightforward and convenient.

Theming with Twig

“Theming” in Bolt is just writing Twig templates. It’s the same thing you’d do on a Symfony or Silex project, and the syntax is just as fun to write. To implement the Vera design, we wrote our own templates from scratch, with neatly organized includes for menus and sidebars, and delicious, delicious template inheritance for the various content types and other special page layouts we needed.

Bolt gives you a default template to get started – you can copy it and make changes as needed.

Bolt is built around Silex

Silex is a fun and rock solid microframework that provides routing and a service container. The main Bolt application is just an extension of the Silex Application class. You probably won’t run into this unless you write an extension, but in that case, you’ll use Silex’s Application methods to gather information about the site, access services (like sessions and the database connection), and safely add new features, all in a completely modular way.

Conclusion: Bolt is awesome

Bolt has a ton to offer developers. It uses well tested, industry standard technologies like YAML, Composer, Twig, Symfony, and Silex to make your life better. Give it a shot, and if you have anything to add, leave a comment below.

Will

Web developer

More Posts

Follow Me:
Twitter