# Creating an extension ## Default extensions In order to organize your custom tags and modifiers, you can create an Extension. In fact, most of Smarty itself is organized into two extensions: - the core extension, which provides the basic language tags such as `{if}`, `{for}` and `{assign}`. - the default extension, which provides all default modifiers such as `|escape`, `|nl2br` and `|number_format` and tags such as `{html_image}`, `{mailto}` and `{textformat}` that are enabled by default, but not necessarily universal. > ** Note ** > > There is also the 'BCPluginsAdapter' extension, which does not add any new functionality, but > wraps calls to deprecated methods such as `Smarty\Smarty::addPluginsDir()` and `Smarty\Smarty::loadFilter()`. ## Writing your own extension In order to write your own custom extension, you must write a class that implements `Smarty\Extension\ExtensionInterface`. However, it is usually easier to extend `Smarty\Extension\Base` which provides empty implementation for each of the methods required by `Smarty\Extension\ExtensionInterface`. This allows you to only override the method(s) you need. Example: ```php addExtension(new MyCustomExtension()); ``` This will add `MyCustomExtension` to the end of the extension list, meaning that you cannot override tags or modifiers from one of Smarty's default extensions. Should you wish to insert your extension at the top of the extension list, or create a very limited Smarty version that only contains the core extension, you can use `Smarty\Smarty::setExtensions()` to override the list of extensions. ```php setExtensions([ new Smarty\Extension\CoreExtension(), new MyCustomExtension(), new Smarty\Extension\DefaultExtension(), ]); ```