PHPackages                             dkhru/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. dkhru/contenttools

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

dkhru/contenttools
==================

ContentTools editor implementation for Yii 2.

06JavaScript

Since Oct 29Pushed 10y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

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

[](#yii2-content-tools)

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": "dev-master"
    }
}

```

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

Usage
-----

[](#usage)

### 1. The widget.

[](#1-the-widget)

Wrap any part of the content with `` and ``.

```

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)

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 2MB), 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 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(),
    ];
}

```

The last "save content" action is not prepared so go ahead and take care of it. 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.

### tag

[](#tag)

*default:* `'div'`Tag that will be used to wrap the editable content.

### dataName

[](#dataname)

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

### dataInit

[](#datainit)

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

### options

[](#options-1)

*default:* `[]`Array of html options that will be 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 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 see the list of prepared translations in '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 *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.

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'`. You can set the `'id'` of the region to be `ModelName[attributeName]` so it can be handled in the standard Yii 2 way (i.e. with load()).

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/60dc5b9b13398fc2e5b645b6ff3af04c3242c4b81393718efecb9d858f56641a?d=identicon)[dkhru](/maintainers/dkhru)

---

Top Contributors

[![dkhru](https://avatars.githubusercontent.com/u/6189646?v=4)](https://github.com/dkhru "dkhru (3 commits)")

### Embed Badge

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

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

###  Alternatives

[guava/calendar

Adds support for vkurko/calendar to Filament PHP.

298241.0k3](/packages/guava-calendar)[demouth/dmgeocoder

Geocoding library.

216.9k](/packages/demouth-dmgeocoder)

PHPackages © 2026

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