Skip to content

Make ext-fileinfo optional and drop composer suggest - #724

Merged
chr-hertel merged 1 commit into
mainfrom
optional-fileinfo
Nov 10, 2026
Merged

chr-hertel merged 1 commit into
mainfrom
optional-fileinfo

Conversation

@chr-hertel

Copy link
Copy Markdown
Member

Only the content factories that read a file need fileinfo, and only when no MIME type is given, so it no longer blocks installing the SDK. Like Symfony, optional dependencies are no longer listed under suggest: the code paths that need them throw an exception that names what to install.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The newly supported configuration lacks test coverage because the only new test requires fileinfo and is skipped, leaving the exception guidance and explicit MIME-type bypass unverified.

1 open issue
What changed in this PR

This PR makes fileinfo optional, allowing SDK installation without it while providing an actionable exception when file-based content needs MIME detection.

Changes:

  • Centralizes MIME detection and missing-extension handling across content factories.
  • Removes Composer suggestions and documents the optional-dependency policy.
  • Adds a MIME-detection unit test and updates installation guidance and the changelog.
File Description
tests/​Unit/​Schema/​Content/​MimeTypeTest.php Tests MIME detection with fileinfo available.
src/​Schema/​Content/​MimeType.php Adds shared detection and an installation-guidance exception.
src/​Schema/​Content/​ImageContent.php Uses shared MIME detection for image files.
src/​Schema/​Content/​EmbeddedResource.php Uses shared detection in file-based resource factories.
src/​Schema/​Content/​BlobResourceContents.php Uses shared detection for file-backed blobs.
src/​Schema/​Content/​AudioContent.php Uses shared MIME detection for audio files.
docs/​get-started/​installation.md Explains explicit MIME types when fileinfo is unavailable.
composer.json Removes the fileinfo requirement and dependency suggestions.
CHANGELOG.md Records optional fileinfo support.
AGENTS.md Documents runtime checks for optional dependencies.

Review effort: Balanced

Comment on lines +28 to +29
if (!\function_exists('mime_content_type')) {
throw new LogicException(\sprintf('Detecting the MIME type of "%s" requires the "fileinfo" PHP extension. Install it or pass the MIME type explicitly.', $path));

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The missing-fileinfo behavior remains untested, leaving both the actionable LogicException and file-factory success with an explicit MIME type unverified when mime_content_type is unavailable.

1 open issue

Review effort: Balanced

@chr-hertel
chr-hertel merged commit 90670d1 into main Nov 10, 2026
61 of 62 checks passed
@chr-hertel chr-hertel added the Schema Issues & PRs related to the Schema component label Nov 10, 2026
@chr-hertel
chr-hertel deleted the optional-fileinfo branch November 10, 2026 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Schema Issues & PRs related to the Schema component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants