PHPackages                             wolfpack-it/yii2-glide - 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. wolfpack-it/yii2-glide

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wolfpack-it/yii2-glide
======================

Yii2 Glide integration

1.0.0(5y ago)01061[1 PRs](https://github.com/wolfpack-it/yii2-glide/pulls)MITPHPPHP &gt;=7.2.0

Since May 31Pushed 3y ago4 watchersCompare

[ Source](https://github.com/wolfpack-it/yii2-glide)[ Packagist](https://packagist.org/packages/wolfpack-it/yii2-glide)[ RSS](/packages/wolfpack-it-yii2-glide/feed)WikiDiscussions master Synced today

READMEChangelog (4)Dependencies (3)Versions (5)Used By (0)

Glide extension for Yii2
========================

[](#glide-extension-for-yii2)

This extension provides [Glide](https://glide.thephpleague.com/) integration for the Yii2 Framework.

[Glide](https://glide.thephpleague.com/) is a package that makes image serving and manipulation really easy. Making use of [Flysystem](http://flysystem.thephpleague.com/) it also abstracts from filesystems.

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

[](#installation)

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

Either run

```
$ composer require wolfpack-it/yii2-glide
```

or add

```
"wolfpack-it/yii2-glide": "^"

```

to the `require` section of your `composer.json` file.

Configuring
-----------

[](#configuring)

### Filesystems

[](#filesystems)

The first step is configuring the filesystems. There can be three:

- The source filesystem (required)
- The cache filesystem (required)
- The watermak filesystem (optional)

Each filesystem can be configured as a component or directly in the container.

Component example:

```
'components' => [
    'glideSource' => [
        'class' => \creocoder\flysystem\LocalFilesystem::class,
        'path' => ''
    ],
]
```

### Component

[](#component)

The configured filesystems can then be used in the Glide configuration:

```
'container' => [
    'definitions' => [
        \WolfpackIT\glide\components\Glide::class => [
            'class' => \WolfpackIT\glide\components\Glide::class,
            'source' => 'glideSource', // via component
            'cache' => [
                'class' => \creocoder\flysystem\LocalFilesystem::class,
                'path' => ''
            ], // via configuration
            'watermarks' => \creocoder\flysystem\AwsS3Filesystem:class // via container
        ]
    ]
]
```

### Controller action

[](#controller-action)

The preferred usage is via an action in the controllers action method:

```
class GlideController extends yii\web\Controller
{
    /**
     * @return array
     */
    public function actions(): array
    {
        return ArrayHelper::merge(
            parent::actions(),
            [
                'index' => [
                    'class' => \WolfpackIT\glide\actions\GlideAction::class
                ]
            ]
        );
    }
}
```

Security
--------

[](#security)

To protect your server agains attacks trying to resize loads of images it is a good idea to protect the urls. A good package for that is [Sam-ITs Url Signer](https://github.com/SAM-IT/yii2-urlsigner). It signs urls with an expiration and can lock the params if you don't want anyone to change images.

It is not included in the package since it is simple to configure:

#### Signer configuration

[](#signer-configuration)

```
'container' => [
    'definitions' => [
        \SamIT\Yii2\UrlSigner\UrlSigner::class => [
            'secret' => '',
        ],
    ]
]
```

#### HMAC filter in controller

[](#hmac-filter-in-controller)

```
class GlideController extends yii\web\Controller
{
    /**
     * @return array
     */
    public function behaviors(): array
    {
        return ArrayHelper::merge(
            [
                HmacFilter::class => [
                    'class' => HmacFilter::class,
                    'signer' => \Yii::$container->get(\SamIT\Yii2\UrlSigner\UrlSigner::class) //via Dependancy Injection
                    'signer' => $this->controller->module->get('') // via component
                ]
            ],
            parent::behaviors()
        );
    }
```

#### Signing urls

[](#signing-urls)

```
$urlSigner = \Yii::createObject(\SamIT\Yii2\UrlSigner\UrlSigner::class);

$url = [
    '/img/index', // NOTE: This must be the route from the root
    'path' => ''
];
$allowAddition = true; // Whether or not to allow image modifications after url generation
$expiration = new DateTime())->add(new DateInterval('P7D'));

$urlSigner->signParams(
    $url,
    $allowAddition,
    $expiration
);

echo yii\helpers\Url::to($url, true);
```

Second security approach
------------------------

[](#second-security-approach)

The package mentioned above requires an expiration which means that every url will be unique every time you generate it. This causes a problem with client side caching. So another approach has been added which unfortunately is a little less pretty implementation but allows for non expiring links. Look [here](https://glide.thephpleague.com/1.0/config/security/)for more information.

#### Signer configuration

[](#signer-configuration-1)

Make sure the key is secure, since the hashing used is only MD5.

```
'container' => [
    'definitions' => [
         \League\Glide\Signatures\Signature::class => function(\yii\di\Container $container) {
            return \League\Glide\Signatures\SignatureFactory::create('');
         },
         \League\Glide\Urls\UrlBuilder::class => function(\yii\di\Container $container) {
             return new \League\Glide\Urls\UrlBuilder('', $container->get(\League\Glide\Signatures\Signature::class));
         },
    ]
]
```

#### Signature filter in controller

[](#signature-filter-in-controller)

```
class GlideController extends yii\web\Controller
{
    /**
     * @return array
     */
    public function behaviors(): array
    {
        return ArrayHelper::merge(
            [
                SignatureFilter::class => [
                    'class' => SignatureFilter::class,
                ]
            ],
            parent::behaviors()
        );
    }
}
```

#### Signing urls

[](#signing-urls-1)

```
$urlBuilder = \Yii::createObject(\League\Glide\Urls\UrlBuilder::class);

$url = [
    '/img/index', // NOTE: This must be the route from the root
    'path' => '',
];

$options = [
    'w' => 1000,
];

echo $urlBuilder->getUrl(Url::to($url), $options);
```

TODO
----

[](#todo)

- Add tests

Credits
-------

[](#credits)

- [Joey Claessen](https://github.com/joester89)
- [Wolfpack IT](https://github.com/wolfpack-it)

License
-------

[](#license)

The MIT License (MIT). Please see [LICENSE](https://github.com/wolfpack-it/yii2-glide/blob/master/LICENSE) for more information.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity57

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.

###  Release Activity

Cadence

Every ~198 days

Total

4

Last Release

1942d ago

Major Versions

v0.2.1 → 1.0.02021-01-15

PHP version history (2 changes)v0.1.0PHP &gt;=7.1.0

1.0.0PHP &gt;=7.2.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/609e8d7caaa1dacc8b03bcc8347b5732e5a91399bb843e5b44fec66be256f35a?d=identicon)[pascalvgemert](/maintainers/pascalvgemert)

![](https://www.gravatar.com/avatar/88359ebe0456645a614e563dfbf0dd025b69ef57221050cb9eb31e3eef4dd0f9?d=identicon)[joester89](/maintainers/joester89)

![](https://www.gravatar.com/avatar/50236d89a220d6eda49f2a6c5a66779f084660c2596ef2c40225b89c4f276efb?d=identicon)[Kavantix](/maintainers/Kavantix)

---

Top Contributors

[![joester89](https://avatars.githubusercontent.com/u/9624366?v=4)](https://github.com/joester89 "joester89 (10 commits)")

### Embed Badge

![Health badge](/badges/wolfpack-it-yii2-glide/health.svg)

```
[![Health](https://phpackages.com/badges/wolfpack-it-yii2-glide/health.svg)](https://phpackages.com/packages/wolfpack-it-yii2-glide)
```

###  Alternatives

[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1452.6k](/packages/dmstr-yii2-cookie-consent)

PHPackages © 2026

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