admin管理员组

文章数量:1400614

I'm facing an issue when trying to install the FilePond library using Symfony's importmap system.

I attempted to add FilePond to my project by running php bin/console importmap:require filepond (or by manually adding an entry in my importmap.php file), followed by php bin/console importmap:install. However, as soon as I run the install command, I get the following error:

In ErrorChunk.php line 73:
  Body size limit exceeded

In Http2ConnectionProcessor.php line 711:
  Body size limit exceeded

In Http2ConnectionProcessor.php line 757:
  Body size limit exceeded

I have tried several solutions to fix this issue:

Increasing the HTTP client's body size limit by modifying the php.ini file (adjusting memory_limit, upload_max_filesize, etc.), and redefining the HTTP client service in services.yaml with the max_body_size option.

Changing the FilePond entry to use a "path" with a direct CDN URL instead of "version", to bypass automatic resolution.

Despite these attempts, the error persists, and I can't properly download the assets from the CDN.

Has anyone encountered this issue with FilePond or other libraries via importmap? Any suggestions on how to bypass this size limit?

Thanks in advance for your help!

I'm facing an issue when trying to install the FilePond library using Symfony's importmap system.

I attempted to add FilePond to my project by running php bin/console importmap:require filepond (or by manually adding an entry in my importmap.php file), followed by php bin/console importmap:install. However, as soon as I run the install command, I get the following error:

In ErrorChunk.php line 73:
  Body size limit exceeded

In Http2ConnectionProcessor.php line 711:
  Body size limit exceeded

In Http2ConnectionProcessor.php line 757:
  Body size limit exceeded

I have tried several solutions to fix this issue:

Increasing the HTTP client's body size limit by modifying the php.ini file (adjusting memory_limit, upload_max_filesize, etc.), and redefining the HTTP client service in services.yaml with the max_body_size option.

Changing the FilePond entry to use a "path" with a direct CDN URL instead of "version", to bypass automatic resolution.

Despite these attempts, the error persists, and I can't properly download the assets from the CDN.

Has anyone encountered this issue with FilePond or other libraries via importmap? Any suggestions on how to bypass this size limit?

Thanks in advance for your help!

Share Improve this question asked Mar 23 at 20:52 QuenKQuenK 11 bronze badge
Add a comment  | 

2 Answers 2

Reset to default 0

The Body size limit exceeded error when running php bin/console importmap:install in Symfony typically occurs because Symfony’s HTTP client enforces a default 10MB response body limit. This limit affects the Importmap system when downloading large JavaScript packages like FilePond.

There are two possible solutions: configure this limit and using CDN

Configure limit

Symfony allows customization of the HTTP client used by the Importmap system. You can override the client and remove the body size restriction safely.

1. In your config/services.yaml, add the following:

services:
    Symfony\Component\AssetMapper\ImportMap\HttpClient\PackageDownloader:
        arguments:
            $client: '@importmap.http_client'

    importmap.http_client:
        class: Symfony\Contracts\HttpClient\HttpClientInterface
        factory: ['Symfony\Component\HttpClient\HttpClient', 'create']
        arguments:
            -
                max_body_length: 0 # 0 means no limit

2. Then clear the cache and reinstall the packages:

php bin/console cache:clear
php bin/console importmap:install

Setting max_body_length: 0 disables the body size limit only for the Importmap-related HTTP client, not for the rest of your application (unless you’ve globally overridden the default HTTP client).

CDN

If you’d rather load FilePond directly from a CDN without downloading it locally, you can run:

php bin/console importmap:require filepond --path=https://unpkg/filepond@^4/dist/filepond.js

This will register the script in your importmap.php, but it will not download it to your local project — it will be loaded from the CDN at runtime.

I found the solution after thoroughly checking Symfony's issues!

The issue was caused by an outdated HTTP client. To fix it, simply update the HTTP client by running:

composer require amphp/http-client

After installing this package, the importmap:install command worked without any issues.

If anyone else encounters the "Body size limit exceeded" error, make sure your HTTP client is up to date. Hope this helps!

本文标签: