Integrates Glide into Charcoal to manipulate images on-demand.
[…] Its straightforward API is exposed via HTTP, similar to cloud image processing services like Imgix and Cloudinary. Glide leverages powerful libraries like Intervention Image (for image handling and manipulation) and Flysystem (for file system abstraction).
This library is available on Packagist and can be installed using Composer:
composer require charcoal/contrib-glide
You can define a single Glide service with a single server:
{
"apis": {
"glide": {
"signature": "signing-key",
"source": "%app.public_path%/uploads"
"cache": "%app.cache_path%/glide",
"defaults": {
"mark": "logo.png",
"markw": "30w",
"markpad": "5w"
},
"presets": {
"thumbnail": {
"w": 300,
"h": 300,
"q": 75,
"fit": "crop"
},
"hero": {
"w": 1600,
"h": 900,
"q": 90,
"fit": "max"
}
}
}
}
}
You can also configure multiple servers, each of which is entirely separate:
{
"apis": {
"glide": {
"signature": "signing-key",
"servers": {
"first": [
"source": "%app.public_path%/uploads/first",
"cache": "%app.cache_path%/glide/first",
"base_url": "/img/",
"max_image_size": 40000,
"presets": [
"invalid_preset": null,
"small_hero": [
"w": 200,
"h": 200,
"fit": "crop",
"nil": null,
],
],
],
"second": [
"source": "%app.public_path%/uploads/second",
"cache": "%app.cache_path%/glide/second",
],
},
"default_server": "first"
}
}
}
With the Glide manager instance, you can retrieve a given server or URL builder, and switch the current server:
$glideManager->getServer('second');
$glideManager->getUrlBuilder('second');
$glideManager->using('second')->getUrlBuilder();
See Glide documentation for more information on configuring servers.
TBD
We appreciate any contribution to the skeleton and Charcoal, whether it's a bug, typo, suggestions, or improvements.
By default, the skeleton is developed with a number of coding style and static code analysis tools:
- [EditorConfig] — Maintain consistent coding styles between different editors.
- JSON Lint — JSON coding style linter.
- PHP Syntax Check — PHP syntax checker from the command line.
- PHP_CodeSniffer (PHPCS) — PHP coding style linter.
- PHPStan — Static PHP code analyser.
- Psalm — Static PHP code analyser.
PHPStan and Psalm are used together to take advantage of each one's specialties.
Linting can be executing by running one of the following commands:
# Run JSON Lint, PHP Lint, PHPCS, PHPStan, and Psalm
composer lint
# Run only JSON Lint
composer lint:json
./vendor/bin/jsonlint config/*.json
# Run only PHP syntax check
composer lint:php
php -l src/*.php
# Run only PHPCS
composer lint:phpcs
./vendor/bin/phpcs -ps --colors src/
# Run only PHPStan
composer lint:phpstan
./vendor/bin/phpstan analyse
# Run only Psalm
composer lint:psalm
./vendor/bin/psalm
By default, PHP tests are located in the tests
directory and developed
with the Pest framework, which internally uses the PHPUnit framework.
Tests can be executing by running one of the following commands:
composer test
composer test:pest
./vendor/bin/pest
🚂