PHPackages                             bizley/contenttools - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. bizley/contenttools

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

bizley/contenttools
===================

ContentTools editor implementation for Yii 2.

1.5.0(6y ago)8016.7k↓42.1%13Apache-2.0PHPCI passing

Since Mar 28Pushed 5y ago7 watchersCompare

[ Source](https://github.com/bizley/yii2-content-tools)[ Packagist](https://packagist.org/packages/bizley/contenttools)[ RSS](/packages/bizley-contenttools/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (4)Versions (7)Used By (0)

yii2-content-tools
==================

[](#yii2-content-tools)

[![Latest Stable Version](https://camo.githubusercontent.com/806fe14800ba4b3e8f8cea01354ba290bd1380f652aede29caa2f936a17d4da6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62697a6c65792f636f6e74656e74746f6f6c732e737667)](https://camo.githubusercontent.com/806fe14800ba4b3e8f8cea01354ba290bd1380f652aede29caa2f936a17d4da6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62697a6c65792f636f6e74656e74746f6f6c732e737667)[![Total Downloads](https://camo.githubusercontent.com/59201e0445b6f630b4fa9517f1ef1bd2632b0fc992ae8cedc6abfdb8bbe27c27/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62697a6c65792f636f6e74656e74746f6f6c732e737667)](https://camo.githubusercontent.com/59201e0445b6f630b4fa9517f1ef1bd2632b0fc992ae8cedc6abfdb8bbe27c27/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62697a6c65792f636f6e74656e74746f6f6c732e737667)[![License](https://camo.githubusercontent.com/b2009fcab7c6e85b98c7df83ecf474d4248a71bffed955ebed85eae40965cc4d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f62697a6c65792f636f6e74656e74746f6f6c732e737667)](https://camo.githubusercontent.com/b2009fcab7c6e85b98c7df83ecf474d4248a71bffed955ebed85eae40965cc4d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f62697a6c65792f636f6e74656e74746f6f6c732e737667)

ContentTools editor implementation for Yii 2.

ContentTools
------------

[](#contenttools)

Check out ContentTools website  for more information about the editor.

Installation
------------

[](#installation)

Add the package to your composer.json:

```
{
    "require": {
        "bizley/contenttools": "^1.4"
    }
}

```

and run `composer update` or alternatively run `composer require bizley/contenttools`

Bower Asset
-----------

[](#bower-asset)

This package depends on Bower package fetched through
Make sure you can fetch it by configuring your composer.json properly (see instructions at the link above).

Usage
-----

[](#usage)

### 1. The widget.

[](#1-the-widget)

Wrap any part of the content in `\bizley\contenttools\ContentTools::begin();` and `\bizley\contenttools\ContentTools::end();`.

```

This is the part of view that is editable.
There are paragraphs
and more...

```

You can use the widget multiple times on one page.

### 2. Backend.

[](#2-backend)

Yii 2 ContentTools saves content and uploaded images asynchronously and it requires some preparation on the backend side.

You have to create few controllers' actions:

- "upload new image" action,
- "rotate uploaded image" action,
- "insert &amp; crop uploaded image" action,
- "save content" action.

Three first actions are already prepared if you don't want any special operations. You can find them in 'actions' folder.

- *UploadAction* - takes care of validating the uploaded images using `\bizley\contenttools\models\ImageForm`(jpg, png and gif images are allowed, maximum width and height is 1000px and maximum size is 2 MB), images are saved in `content-tools-uploads` folder accessible from web.
- *RotateAction* - takes care of rotating the uploaded image using Imagine library (through `yii2-imagine` extension required in the composer.json).
- *InsertAction* - takes care of inserting image into the content with optional cropping using Imagine library.

The default option for the image URLs is:

```
'imagesEngine' => [
    'upload' => '/site/content-tools-image-upload',
    'rotate' => '/site/content-tools-image-rotate',
    'insert' => '/site/content-tools-image-insert',
],

```

So if you don't want to change the `imagesEngine` parameter add in your SiteController:

```
public function actions()
{
    return [
        'content-tools-image-upload' => \bizley\contenttools\actions\UploadAction::className(),
        'content-tools-image-insert' => \bizley\contenttools\actions\InsertAction::className(),
        'content-tools-image-rotate' => \bizley\contenttools\actions\RotateAction::className(),
    ];
}

```

See [Standalone Actions section in Yii 2 Guide](https://www.yiiframework.com/doc/guide/2.0/en/structure-controllers#standalone-actions)for more info about adding actions.

The last "save content" action is not prepared because it depends on the business logic of your application. See *Saving content* part at the end of this file.

Default configuration for this is:

```
'saveEngine' => [
    'save' => '/site/save-content',
],

```

Options
-------

[](#options)

You can add options for the widget by passing the configuration array in the `begin()` method.

### id

[](#id)

*default:* `null`
Identifier of the editable region (must be unique). If left empty it is automatically set to 'contentToolsXXX' where XXX is the number of next widget.

### page

[](#page)

*default:* `null`
Page identifier. If `null` it is set to the current URL.

### tag

[](#tag)

*default:* `'div'`
HTML tag that is used to wrap the editable content.

### dataName

[](#dataname)

*default:* `'name'`
Name of the `data-*` attribute that stores the identifier of editable region.

### dataInit

[](#datainit)

*default:* `'editable'`
Name of the `data-*` attribute that marks the region as editable.

### options

[](#options-1)

*default:* `[]`
Array of HTML options that are applied to editable region's tag.

### imagesEngine

[](#imagesengine)

*default:*

```
[
    'upload' => '/site/content-tools-image-upload',
    'rotate' => '/site/content-tools-image-rotate',
    'insert' => '/site/content-tools-image-insert',
]

```

Array of the URLs of the image actions *OR* `false` to switch off the default image engine (you will have to prepare JS for handling images on your own).

### saveEngine

[](#saveengine)

*default:*

```
[
    'save' => '/site/save-content',
]

```

Array with the URL of the content saving action *OR* `false` to switch off the default saving engine (you will have to prepare JS for handling content saving on your own).

### styles

[](#styles)

*default:* `[]`
Array of styles that can be applied to the edited content.
Every style should be added in separate array like:

```
'Name of the style' => [
    'class' => 'Name of the CSS class',
    'tags'  => [Array of the html tags this can be applied to] or 'comma-separated list of the html tags this can be applied to'
],

```

Example:

```
'Bootstrap Green' => [
    'class' => 'text-success',
    'tags'  => ['p', 'h2', 'h1']
],

```

`tags` key is optional and if omitted style can be applied to every element.

### language

[](#language)

*default:* `false`
Boolean flag or language code of the widget translation.
You can find the list of prepared translations in `@bower/contenttools/translations` folder.
`false` means that widget will not be translated (default language is English).
`true` means that widget will be translated using the application language.
If this parameter is a string widget tries to load the translation file with the given name.
If it cannot be found and string is longer that 2 characters widget tries again this time with parameter shortened to 2 characters.
If again it cannot be found language sets back to default.

### globalConfig

[](#globalconfig)

*default:* `true`
Boolean flag whether the configuration should be global.
Global configuration means that every succeeding widget ignores `page`, `tag`, `dataName`, `dataInit`, `imagesEngine`, `saveEngine`, and `language` parameters and sets them to be the same as in the first one. Also `styles` are added only if they've got unique names.

### customJs

[](#customjs)

*default:* `null`
String with custom JS to be initialized with editor.
Use `editor` variable to point to instance of `ContentTools.EditorApp.get()`.
See  for more details about CT API.

Actions callbacks
-----------------

[](#actions-callbacks)

The default JS image callbacks assume the following action response:

```
{
    'size': [image-width-in-px, image-height-in-px],
    'url': image-url
}

```

with optional `'alt'` for insert-action. In case of any errors response should be:

```
{
    'errors': [array-of-error-descriptions]
}

```

At the moment errors are only displayed in browser's console (user sees only the big transparent cross).

Saving content
--------------

[](#saving-content)

Action responsible for saving the content should expect the array of every page region data in pairs `'region-identifier' => 'region-content'`.

Typical structure could look like this:

```
[
    'contentTools0' => '...', // HTML content of the contentTools0 region
    'contentTools1' => '...', // HTML content of the contentTools1 region
    '_csrf' => '...', // CRSF token value
    'page' => '/site/index' // page identifier
]

```

Now you just need to validate and save the regions linked to the page with the given identifier.

**Example implementation of saving content can be found in the **

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity41

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~263 days

Recently: every ~159 days

Total

6

Last Release

2385d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b33b799410f9cb8d69a27bce7ae65d5c0a0aa8e097b2624c2f5315400d653b38?d=identicon)[bizley](/maintainers/bizley)

---

Top Contributors

[![jeffrico](https://avatars.githubusercontent.com/u/3632182?v=4)](https://github.com/jeffrico "jeffrico (2 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (1 commits)")

---

Tags

contenttoolshacktoberfestwidgetwysiwygyii2htmlyii2extensionwidgeteditorwysiwygcontenttools

### Embed Badge

![Health badge](/badges/bizley-contenttools/health.svg)

```
[![Health](https://phpackages.com/badges/bizley-contenttools/health.svg)](https://phpackages.com/packages/bizley-contenttools)
```

###  Alternatives

[bizley/quill

Quill editor implementation for Yii 2.

64133.3k5](/packages/bizley-quill)[kartik-v/yii2-editors

Editor widgets Yii2 framework. Summernote WYSIWYG editor, Codemirror code editor and PlainText editor for Bootstrap 3.x, 4.x and 5.x.

23300.9k1](/packages/kartik-v-yii2-editors)[jodit/yii2-jodit

Jodit - awesome WYSIWYG Editor like widget for Yii2

1621.5k](/packages/jodit-yii2-jodit)[richardfan1126/yii2-js-register

Yii2 widget to register JS into view

1357.2k7](/packages/richardfan1126-yii2-js-register)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
