BoltCM

Sophisticated, Lightweight and Simple

Jump to docs navigation
Edit on GitHub

Extending » Basics » About

What can you do with Bolt extensions?

The functionality of Bolt can be extended by creating Extensions. The possibilities are almost limitless but here are a few of the basic ideas that can be accomplished:

A Bolt extension has to follow a few strict rules, so it can be auto-loaded by Bolt and to make sure it won't interfere with other Bolt functionality or even other Extensions.

To do this, we have to keep the following rules:

To get the hang of how extensions work, there are a few resource/examples extensions that can be used to follow:

The two "starter" extensions are commented with lots of information and are good learning resources. The "stencil" extension however is just that, something you can make a copy of and remove everything you don't need.

It may also be worth look for other popular extensions on the Marketplace. They all have a link to the source code on the information page.

Coding your extensions

Because Bolt is written in PHP, it should be no surprise that the extensions must also be written in PHP. Bolt is built upon the awesome Silex micro- framework, and uses a lot of components from the Symfony framework.

When coding your extensions, you should use as much of the functionality provided by Silex and the included components as possible. Don't re-invent the wheel, and things like that.

See the chapter on Bolt internals for a detailed overview of the provided Bolt functionality, Silex objects and included libraries.

Bolt strives to adhere to the PSR-2 coding style. When writing your extensions, you should try to do the same.

Getting Started

To create your extension the easiest way is to create a Composer project from the Starter Extension:

composer create-project --no-install bolt/bolt-extension-starter:^3.0 <newextname>

If you're wanting something geared a little toward learning about different parts of a Bolt extension, you will be better of creating a "sample" extension from the Extended Starter Extension

composer create-project --no-install bolt/bolt-extension-starter-extended:^3.0 <newextname>

Finally, once you're comfortable with creating extensions and you want a more complete baseline to start new extensions from, you can use the Stencil

composer create-project --no-install bolt/bolt-extension-stencil:^3.0 <newextname>

Further reading

If you want to delve deeper into what you can and cannot do with extensions, see the chapter on Bolt internals for a detailed overview of the provided Bolt functionality, Silex objects and included libraries.


Couldn't find what you were looking for? We are happy to help you in the forum, on Slack or on IRC.
Spotted a typo, or have something to add? Edit this page on GitHub.