Skip to content
This repository has been archived by the owner on Oct 27, 2019. It is now read-only.
/ glide-module Public archive

[EXPERIMENTAL] Glide integration for definition-interop compatible frameworks and containers

License

Notifications You must be signed in to change notification settings

mnapoli/glide-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Glide universal module

This package integrates Glide in any container-interop compatible framework/container.

Installation

composer require mnapoli/glide-module

Once installed, you need to register the GlideModule\GlideServiceProvider into your container.

Refer to your framework or container's documentation to learn how to register service providers.

Usage

This module registers the Glide server under the League\Glide\Server key in your service container. You can now inject it in your services. Have a look at the official documentation to know how to use the server.

Since Glide's server requires the source and cache options to be configured, you must define a glide.options entry in your container. That entry should be an array containing Glide options.

Here is an example using PHP-DI's syntax:

return [
    'glide.options' => [
        'source' => 'path/to/source/folder',
        'cache' => 'path/to/cache/folder',
    ]
];

Here is the same example using Pimple:

$pimple['glide.options'] = [
    'source' => 'path/to/source/folder',
    'cache' => 'path/to/cache/folder',
];

Returning a response

This module automatically configures Glide to generate PSR-7 responses. To use it in a controller, simply inject the League\Glide\Server object and use it like this:

// This returns a PSR-7 response
return $server->getImageResponse($filename, $options);

Advanced options

The glide.options array is passed straight to Glide's ServerFactory. Have a look at the official documentation about configuration to learn about all the options you can use.

About

[EXPERIMENTAL] Glide integration for definition-interop compatible frameworks and containers

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages