Getting Ready for v2027 (I)

Part 5: Enable Brotli (br) Compression on Apache

Now that HTTP/2 is enabled, the next big web server performance win is Brotli compression (Content-Encoding: br).

Brotli achieves 15% to 25% better compression than Gzip for text, CSS, JavaScript, JSON, and SVG assets. Just like HTTP/2, enabling Brotli shrinks transfer sizes and speeds up your existing v2026 (or older) projects today, and it will be even more helpful in v2027.

Step 1: Enable Required Apache Modules

For Brotli compression, Apache requires mod_brotli and mod_filter. Enabling mod_deflate is optional, but recommended as a Gzip fallback for older clients and proxies.

Modules Breakdown

  • mod_brotli (brotli_module — Required): Delivers Brotli compression (Content-Encoding: br). Note: Requires Apache 2.4.26 or later (standard in modern WAMP/XAMPP).
  • mod_filter (filter_module — Required): Crucial prerequisite! Enables smart output filtering by MIME type (AddOutputFilterByType) so Apache only compresses text, scripts, stylesheets, and JSON, without wasting CPU on binary files.
  • mod_setenvif (setenvif_module — Required): Allows excluding already compressed formats (images, videos, fonts, archives) via SetEnvIfNoCase.
  • mod_deflate (deflate_module — Optional, Recommended): Provides standard Gzip fallback (Content-Encoding: gzip) when a browser or proxy does not send br in Accept-Encoding. If omitted, clients without Brotli support will receive uncompressed content.

How to Enable the Modules

Choose either the WampServer GUI or direct httpd.conf configuration:

Option A: Via WampServer GUI

  1. Left-click the WampServer icon in your Windows taskbar notification area.
  2. Navigate to Apache -> Apache modules.
  3. Ensure the following modules are checked (Apache will reload automatically):
    • brotli_module (Required)
    • filter_module (Required)
    • setenvif_module (Required)
    • deflate_module (Optional, recommended fallback)

Option B: Via httpd.conf (Direct Config for Standalone Apache / XAMPP / WAMP)

  1. Open httpd.conf in your editor (e.g. D:\wamp64\bin\apache\apache2.4.x\conf\httpd.conf or D:\xampp\apache\conf\httpd.conf).
  2. Search for LoadModule and ensure the following lines are uncommented (remove the leading # if present):
    LoadModule brotli_module modules/mod_brotli.so
    LoadModule deflate_module modules/mod_deflate.so
    LoadModule filter_module modules/mod_filter.so
    LoadModule setenvif_module modules/mod_setenvif.so
    
  3. Save the file and restart Apache.

Verify Loaded Modules

You can verify that Apache has loaded all compression-related modules by opening a Command Prompt (e.g. in D:\wamp64\bin\apache\apache2.4.x\bin) and running:

httpd -M | findstr /i "brotli deflate filter"

(On Linux: apache2ctl -M | grep -E "brotli|deflate|filter")

Expected output:

 brotli_module (shared)
 deflate_module (shared)
 filter_module (shared)

Step 2: Configure Compression Rules

PHPMaker 2026 does not include Brotli rules in its generated .htaccess by default. You have two options:

Option 1: Global Apache Config (Recommended)
Place the rules below directly inside your httpd.conf or <VirtualHost> block. That way, all your local projects benefit automatically without modifying individual .htaccess files.

Option 2: Project .htaccess
Or add this block to the bottom of your v2026 project's .htaccess file:

# Brotli Compression
<IfModule mod_filter.c>
    <IfModule mod_brotli.c>
        AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css \
            text/javascript application/javascript application/x-javascript \
            application/json application/xml application/rss+xml \
            application/vnd.ms-fontobject application/wasm \
            image/svg+xml font/ttf font/otf font/eot

        # Don't double-compress already compressed formats
        <IfModule mod_setenvif.c>
            SetEnvIfNoCase Request_URI \.(?:gz|zip|br|zst|woff2|png|jpe?g|gif|webp)$ no-brotli
        </IfModule>
    </IfModule>
</IfModule>

# Gzip fallback for clients/proxies that don't support Brotli
<IfModule mod_filter.c>
    <IfModule mod_deflate.c>
        AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css \
            text/javascript application/javascript application/x-javascript \
            application/json application/xml application/rss+xml \
            application/vnd.ms-fontobject application/wasm \
            image/svg+xml font/ttf font/otf font/eot

        <IfModule mod_setenvif.c>
            SetEnvIfNoCase Request_URI \.(?:gz|zip|br|zst|woff2|png|jpe?g|gif|webp)$ no-gzip dont-vary
        </IfModule>
    </IfModule>
</IfModule>

Restart Apache after making any configuration changes.

v2027 will include above Brotli and Deflate configuration rules in the generated .htaccess out-of-the-box!

Then make sure your VirtualHost or <Directory> block has AllowOverride All enabled so .htaccess can take effect, e.g.

<Directory "D:/wamp64/www/your-project">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

Step 3: Verify in Browser DevTools

  1. Open DevTools (F12) -> Network tab.
  2. Check Disable cache and hard-refresh (Ctrl + F5).
  3. Click any .js or .css file and check the Response Headers:
    Content-Encoding: br
    
  4. If you add the Size column in DevTools, you will notice the transferred size over the network is significantly smaller than the actual resource size.

Pre-Compressed Assets (v2027)

In v2027 production builds, you will be able to enable Tools -> Advanced Settings -> Pre-compress assets (brotli, zstandard, or gzip). Symfony will generate pre-compressed .br / .zst / .gz files at compile time so Apache serves them directly from disk with zero runtime CPU overhead.

For pre-compressed serving in Apache, also make sure rewrite_module, headers_module, and mime_module are enabled.

(Next up: Getting Ready for v2027 (II))