PHPackages                             codificar/yii2imagecache - 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. [Caching](/categories/caching)
4. /
5. codificar/yii2imagecache

ActiveYii2-extension[Caching](/categories/caching)

codificar/yii2imagecache
========================

ImageCache for Yii2

0.0.5(4y ago)02.6kMITPHP

Since Jul 21Pushed 4y ago1 watchersCompare

[ Source](https://github.com/codificar/yii2imagecache)[ Packagist](https://packagist.org/packages/codificar/yii2imagecache)[ Docs](https://github.com/codificar/yii2imagecache)[ RSS](/packages/codificar-yii2imagecache/feed)WikiDiscussions main Synced 5d ago

READMEChangelog (5)Dependencies (1)Versions (6)Used By (0)

 [ ![Codificar](https://camo.githubusercontent.com/b58cef801953a2b39d120cb9438d826e8fa010cab422c318e8b4fb8519f7e11f/68747470733a2f2f636f646966696361722e636f6d2e62722f77702d636f6e74656e742f75706c6f6164732f323031392f30342f6c6f676f2d636f642e706e672e77656270) ](https://github.com/codificar/yii2imagecache)

 [ Yii2 ImageCache ](https://github.com/codificar/yii2imagecache)
=================================================================

[](#------yii2-imagecache--)

 Biblioteca desenvolvida pela Codificar .

 [ ![React Native is released under the MIT license.](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667) ](https://github.com/facebook/react-native/blob/master/LICENSE) [ ![Versão](https://camo.githubusercontent.com/f3449860ece3f8384685111598f7dad09a66674d0f404a93ca98733bb2c84357/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f766572732543332541336f2d302e302e352d677265656e) ](https://github.com/codificar/yii2imagecache/releases/) [ ![Downloads](https://camo.githubusercontent.com/1f61f0ee37936eebb003493108f5cb52d022a47ac953e2510dce52de62b7cb36/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636f646966696361722f79696932696d61676563616368652e737667) ](https://packagist.org/packages/codificar/yii2imagecache/stats)

Based in [yii2-imagecache](https://github.com/iutbay/yii2-imagecache)

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

[](#installation)

The preferred way to install this helper is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require "codificar/yii2imagecache" "0.0.5"

```

or add

```
"codificar/yii2imagecache" : "0.0.5"
```

to the require section of your application's `composer.json` file.

Configuration
-------------

[](#configuration)

You should :

- Add `ThumbAction` in one of your controller.
- Modify your application configuration :
    - add *imageCache* component,
    - add url rule to handle request to missing thumbs.

### Add *ThumbAction*

[](#add-thumbaction)

You need to add `ThumbAction` in one of your controller so that imageCache can handle requests to missing thumbs and create them on demand. You could use `site` controller :

```
class SiteController extends Controller
{
  ...
  public function actions()
  {
      return [
        ...
        'thumb' => 'codificar\yii2imagecache\ThumbAction',
        ...
      ];
  }
  ...
}
```

### *imageCache* component config

[](#imagecache-component-config)

You should add *imageCache* component in your application configuration :

```
$config = [
    'components' => [
      ...
      'imageCache' => [
        'class' => 'iutbay\yii2imagecache\ImageCache',
        'sourcePath' => '@app/web/images',
        'sourceUrl' => '@web/images',
        //'thumbsPath' => '@app/web/thumbs',
        //'thumbsUrl' => '@web/thumbs',
        //'sizes' => [
        //    'thumb' => [150, 150],
        //    'medium' => [300, 300],
        //    'large' => [600, 600],
        //],
      ],
      ...
    ],
];
```

### *urlManager* config

[](#urlmanager-config)

You should modify your *urlManager* configuration :

```
$config = [
    'components' => [
      ...
      'urlManager' => [
        'enablePrettyUrl' => true,
        'showScriptName' => false,
        'rules' => [
          ...
          'thumbs/' => 'site/thumb',
          ...
        ],
      ],
      ...
    ],
];
```

How to use
----------

[](#how-to-use)

```
