Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
require_once(__DIR__ . '/deployer/requirements/task/check_locales.php');
require_once(__DIR__ . '/deployer/requirements/task/check_packages.php');
require_once(__DIR__ . '/deployer/requirements/task/check_image_processing.php');
require_once(__DIR__ . '/deployer/requirements/task/check_media_support.php');
require_once(__DIR__ . '/deployer/requirements/task/check_php_extensions.php');
require_once(__DIR__ . '/deployer/requirements/task/check_php_settings.php');
require_once(__DIR__ . '/deployer/requirements/task/check_database.php');
Expand Down
1 change: 1 addition & 0 deletions deployer/requirements/config/set.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
set('requirements_check_locales_enabled', true);
set('requirements_check_packages_enabled', true);
set('requirements_check_image_processing_enabled', true);
set('requirements_check_media_support_enabled', true);
set('requirements_check_php_extensions_enabled', true);
set('requirements_check_php_settings_enabled', true);
set('requirements_check_database_enabled', true);
Expand Down
123 changes: 123 additions & 0 deletions deployer/requirements/task/check_media_support.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?php

declare(strict_types=1);

namespace Deployer;

use Deployer\Exception\RunException;

task('requirements:check:media_support', function (): void {
if (!get('requirements_check_media_support_enabled')) {
return;
}

checkGdFormatSupport();
checkImageToolFormatSupport();
checkBrotliExtension();
})->hidden();

function checkGdFormatSupport(): void
{
$formats = ['AVIF' => 'AVIF Support', 'WebP' => 'WebP Support'];

try {
$gdJson = run('php -r "echo function_exists(\'gd_info\') ? json_encode(gd_info()) : \'null\';" 2>/dev/null');
} catch (RunException) {
foreach ($formats as $label => $key) {
addRequirementRow("GD: $label Support", REQUIREMENT_SKIP, 'Could not query GD');
}

return;
}

$gdInfo = json_decode($gdJson, true);

if (!is_array($gdInfo)) {
foreach ($formats as $label => $key) {
addRequirementRow("GD: $label Support", REQUIREMENT_SKIP, 'GD not available');
}

return;
}

foreach ($formats as $label => $key) {
$supported = !empty($gdInfo[$key]);
addRequirementRow(
"GD: $label Support",
$supported ? REQUIREMENT_OK : REQUIREMENT_WARN,
$supported ? 'Supported' : 'Not compiled into GD'
);
}
}

function checkImageToolFormatSupport(): void
{
$formats = ['AVIF' => 'AVIF', 'WEBP' => 'WebP'];
$formatList = null;
$toolLabel = null;

// Try GraphicsMagick first
try {
$output = run('gm convert -list format 2>/dev/null');

if ('' !== trim($output)) {
$formatList = $output;
$toolLabel = 'GraphicsMagick';
}
} catch (RunException) {
// not available
}

// Fallback to ImageMagick
if (null === $formatList) {
foreach (['magick', 'convert'] as $imCommand) {
try {
$output = run("$imCommand -list format 2>/dev/null");

if ('' !== trim($output)) {
$formatList = $output;
$toolLabel = 'ImageMagick';

break;
}
} catch (RunException) {
continue;
}
}
}

if (null === $formatList || null === $toolLabel) {
foreach ($formats as $label) {
addRequirementRow("IM/GM: $label", REQUIREMENT_SKIP, 'No image processing tool found');
}

return;
}

foreach ($formats as $formatKey => $label) {
$supported = (bool) preg_match('/^\s*' . $formatKey . '\b/mi', $formatList);
addRequirementRow(
"$toolLabel: $label",
$supported ? REQUIREMENT_OK : REQUIREMENT_WARN,
$supported ? 'Supported' : 'Format not supported'
);
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}

function checkBrotliExtension(): void
{
try {
$modules = strtolower(run('php -m 2>/dev/null'));
} catch (RunException) {
addRequirementRow('PHP ext: brotli', REQUIREMENT_SKIP, 'Could not retrieve PHP modules');

return;
}

$loaded = in_array('brotli', array_map('trim', explode("\n", $modules)), true);
addRequirementRow(
'PHP ext: brotli',
$loaded ? REQUIREMENT_OK : REQUIREMENT_WARN,
$loaded ? 'Loaded' : 'Not loaded'
);
}
1 change: 1 addition & 0 deletions deployer/requirements/task/requirements.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
'requirements:check:locales',
'requirements:check:packages',
'requirements:check:image_processing',
'requirements:check:media_support',
'requirements:check:php_extensions',
'requirements:check:php_settings',
'requirements:check:database',
Expand Down
18 changes: 17 additions & 1 deletion docs/REQUIREMENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ $ dep requirements:list [host]
## Checks

### Locales

Verifies that required system locales are available (default: `de_DE.utf8`, `en_US.utf8`).

### System packages
Expand All @@ -32,6 +31,20 @@ Checks for required CLI tools: rsync, curl, ghostscript, git, gzip, mariadb-clie

Checks for GraphicsMagick (>= 1.3, recommended) or ImageMagick (>= 6.0) with version validation. Either one is sufficient.

### Media support

Checks for modern media format support across the PHP GD library and the installed image processing tool (GraphicsMagick or ImageMagick):

| Check | Method | OK | WARN | SKIP |
|-------|--------|----|------|------|
| GD: AVIF Support | `gd_info()` key `AVIF Support` | Compiled into GD | Not compiled into GD | GD not available |
| GD: WebP Support | `gd_info()` key `WebP Support` | Compiled into GD | Not compiled into GD | GD not available |
| IM/GM: AVIF | Format list (`-list format`) | Format supported | Format not supported | No tool found |
| IM/GM: WebP | Format list (`-list format`) | Format supported | Format not supported | No tool found |
| PHP ext: brotli | `php -m` | Loaded | Not loaded | — |

All checks use WARN (not FAIL) since these features are recommended but not strictly required.
Comment thread
coderabbitai[bot] marked this conversation as resolved.

### PHP version

Validates the PHP version against the configured minimum (TYPO3: >= 8.2.0, default: >= 8.1.0).
Expand Down Expand Up @@ -158,6 +171,9 @@ set('requirements_packages', [
set('requirements_mariadb_min_version', '10.6.0');
set('requirements_mysql_min_version', '8.0.30');

// Disable media support checks (AVIF, WebP, brotli)
set('requirements_check_media_support_enabled', false);

// Override image processing minimum versions
set('requirements_graphicsmagick_min_version', '1.3.30');
set('requirements_imagemagick_min_version', '7.0');
Expand Down