PHPackages                             admad/cakephp-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. [Image &amp; Media](/categories/media)
4. /
5. admad/cakephp-glide

ActiveCakephp-plugin[Image &amp; Media](/categories/media)

admad/cakephp-glide
===================

CakePHP plugin for using Glide image manipulation library.

7.0.0(1y ago)34168.2k↓26.3%111MITPHPPHP &gt;=8.1CI failing

Since Dec 27Pushed 1y ago7 watchersCompare

[ Source](https://github.com/ADmad/cakephp-glide)[ Packagist](https://packagist.org/packages/admad/cakephp-glide)[ Docs](https://github.com/ADmad/cakephp-glide)[ GitHub Sponsors](https://github.com/ADmad)[ RSS](/packages/admad-cakephp-glide/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)Dependencies (3)Versions (25)Used By (1)

CakePHP Glide
=============

[](#cakephp-glide)

[![Build Status](https://camo.githubusercontent.com/427da53c8ef424ccc3ae2ec10dc16a3a6fd9abe6f5ff9a92d1d818b80959c0fb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f41446d61642f63616b657068702d676c6964652f63692e796d6c3f7374796c653d666c61742d737175617265266272616e63683d6d6173746572)](https://github.com/ADmad/cakephp-glide/actions?query=workflow%3ACI+branch%3Amaster)[![Coverage Status](https://camo.githubusercontent.com/830283517e8ba603609db7b10a7e922cb6741f1ae0e85f35039feb8de5f1a7d5/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f41446d61642f63616b657068702d676c6964652e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/github/ADmad/cakephp-glide)[![Total Downloads](https://camo.githubusercontent.com/261f0e486dff1e9b461536febac049ae8053266685bed26095fe56b69829d985/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f41446d61642f63616b657068702d676c6964652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ADmad/cakephp-glide)[![License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE.txt)

CakePHP plugin to help using [Glide](http://glide.thephpleague.com/) image manipulation library.

The plugin consists of a middlware, view helper and a Glide response class.

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

[](#installation)

Install the plugin through composer:

```
composer require admad/cakephp-glide

```

Load the plugin using CLI:

```
bin/cake plugin load ADmad/Glide
```

Usage
-----

[](#usage)

### Middleware

[](#middleware)

In your `config/routes.php` setup the `GlideMiddleware` for required scope which intercepts requests and serves images generated by Glide. For e.g.:

```
$routes->scope('/images', function ($routes) {
    $routes->registerMiddleware('glide', new \ADmad\Glide\Middleware\GlideMiddleware([
        // Run this middleware only for URLs starting with specified string. Default null.
        // Setting this option is required only if you want to setup the middleware
        // in Application::middleware() instead of using router's scoped middleware.
        // It would normally be set to same value as that of server.base_url below.
        'path' => null,

        // Either a callable which returns an instance of League\Glide\Server
        // or config array to be used to create server instance.
        // http://glide.thephpleague.com/1.0/config/setup/
        'server' => [
            // Path or League\Flysystem adapter instance to read images from.
            // http://glide.thephpleague.com/1.0/config/source-and-cache/
            'source' => WWW_ROOT . 'uploads',

            // Path or League\Flysystem adapter instance to write cached images to.
            'cache' => WWW_ROOT . 'cache',

            // URL part to be omitted from source path. Defaults to "/images/"
            // http://glide.thephpleague.com/1.0/config/source-and-cache/#set-a-base-url
            'base_url' => '/images/',

            // Response class for serving images. If unset (default) an instance of
            // \ADmad\Glide\Response\PsrResponseFactory() will be used.
            // http://glide.thephpleague.com/1.0/config/responses/
            'response' => null,
        ],

        // http://glide.thephpleague.com/1.0/config/security/
        'security' => [
            // Boolean indicating whether secure URLs should be used to prevent URL
            // parameter manipulation. Default false.
            'secureUrls' => false,

            // Signing key used to generate / validate URLs if `secureUrls` is `true`.
            // If unset value of Cake\Utility\Security::salt() will be used.
            'signKey' => null,
        ],

        // Cache duration. Default '+1 days'.
        'cacheTime' => '+1 days',

        // Any response headers you may want to set. Default null.
        'headers' => [
            'X-Custom' => 'some-value',
        ],

        // Allowed query string params. If for e.g. you are only using glide presets
        // then you can set allowed params as `['p']` to prevent users from using
        // any other image manipulation params.
        'allowedParams' => null
    ]));

    $routes->applyMiddleware('glide');

    $routes->connect('/*');
});
```

For the example config shown above, for URL like `domain.com/images/user/profile.jpg`the source image should be under `webroot/uploads/user/profile.jpg`.

**Note**: Make sure the image URL does not directly map to image under webroot. Otherwise as per CakePHP's default URL rewriting rules the image will be served by webserver itself and request won't reach your CakePHP app.

#### Exceptions

[](#exceptions)

If you have enabled secure URLs and a valid token is not present in query string the middleware will throw a `ADmad\Glide\Exception\SignatureException` exception.

If a response image could not be generated by the Glide library then by default the middleware will throw a `ADmad\Glide\Exception\ResponseException`. A `Glide.response_failure` event will also be triggered in this case. You can setup a listener for this event and return a response instance from it. In this case that response will be sent to client and `ResponseException` will not be thrown.

```
\Cake\Event\EventManager::instance()->on(
    \ADmad\Glide\Middleware\GlideMiddleware::RESPONSE_FAILURE_EVENT,
    function ($event) {
        return (new Response())
            ->withFile('/path/to/default-image.jpg');
    }
);
```

### Helper

[](#helper)

The provided `GlideHelper` helps creating URLs and image tags for generating images. You can load the helper in your `AppView::initialize()` as shown in example below:

```
public function initialize(): void
{
    // All option values should match the corresponding options for `GlideFilter`.
    $this->loadHelper('ADmad/Glide.Glide', [
        // Base URL.
        'baseUrl' => '/images/',
        // Whether to generate secure URLs.
        'secureUrls' => false,
        // Signing key to use when generating secure URLs.
        'signKey' => null,
    ]);
}
```

Here are the available methods of `GlideHelper`:

```
    /**
     * Creates a formatted IMG element.
     *
     * @param string $path Image path.
     * @param array $params Image manipulation parameters.
     * @param array $options Array of HTML attributes and options.
     *   See `$options` argument of `Cake\View\HtmlHelper::image()`.
     * @return string Complete  tag.
     */
    GlideHelper::image(string $path, array $params = [], array $options = []): string

    /**
     * URL with query string based on resizing params.
     *
     * @param string $path Image path.
     * @param array $params Image manipulation parameters.
     * @return string Image URL.
     */
    GlideHelper::url(string $path, array $params = []): string
```

The main benefit of using this helper is depending on the value of `secureUrls`config, the generated URLs will contain a token which will be verified by the middleware. The prevents modification of query string params.

###  Health Score

51

—

FairBetter than 95% of packages

Maintenance41

Moderate activity, may be stable

Popularity45

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 97.8% 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 ~153 days

Recently: every ~293 days

Total

23

Last Release

490d ago

Major Versions

3.1.0 → 4.0.0-beta2019-12-17

3.1.1 → 4.0.02021-03-01

4.x-dev → 5.0.0-beta2021-03-04

5.x-dev → 6.0.02023-09-28

6.x-dev → 7.0.02025-03-21

### Community

Maintainers

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

---

Top Contributors

[![ADmad](https://avatars.githubusercontent.com/u/142658?v=4)](https://github.com/ADmad "ADmad (177 commits)")[![Spriz](https://avatars.githubusercontent.com/u/3512268?v=4)](https://github.com/Spriz "Spriz (3 commits)")[![josegonzalez](https://avatars.githubusercontent.com/u/65675?v=4)](https://github.com/josegonzalez "josegonzalez (1 commits)")

---

Tags

cakephpcakephp-pluginimage-processingmiddlewarephpthumbnailimageImageMagickgdimagickmanipulationprocessingleagueeditingcakephpglide

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/admad-cakephp-glide/health.svg)

```
[![Health](https://phpackages.com/badges/admad-cakephp-glide/health.svg)](https://phpackages.com/packages/admad-cakephp-glide)
```

###  Alternatives

[league/glide

Wonderfully easy on-demand image manipulation library with an HTTP based API.

2.6k53.3M149](/packages/league-glide)[intervention/image

PHP Image Processing

14.4k208.9M2.6k](/packages/intervention-image)[intervention/image-laravel

Laravel Integration of Intervention Image

1588.9M201](/packages/intervention-image-laravel)[talesoft/phim

An image and color manipulation and processing library for PHP

2959.0k1](/packages/talesoft-phim)[james-heinrich/phpthumb

The PHP thumbnail generator

317561.0k20](/packages/james-heinrich-phpthumb)[orbitale/imagemagick-php

A system that allows creating commands to send to the exec() function to use ImageMagick's powerful features.

42418.0k1](/packages/orbitale-imagemagick-php)

PHPackages © 2026

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