Skip to content

Compatibility issues with PHP 8.5 #1127

Open

Description

@MatDepInfo

Hello,
I use SendGrid with PHP 8.5 and got:

Function curl_close() is deprecated since 8.5, as it has no effect since PHP 8.0 in vendor/sendgrid/php-http-client/lib/Client.php

Activity

  1. alekr-jsausa commented on Feb 3, 2026

    @alekr-jsausa

    I am running into this issue as well. I think it can be fixed by replacing the offending line with:

    if (PHP_MAJOR_VERSION < 8) {
        curl_close($channel);
    }

    to keep compatibility with PHP 7. I'm happy to file a PR for this if that's what is needed to get this fixed.

  2. slipszenko commented on Feb 6, 2026

    @slipszenko

    This is in a library used by this library, and has a couple of PRs open:

    It'd be great to see one of those merged.

  3. andreas-aeschlimann commented on Feb 8, 2026

    @andreas-aeschlimann
    Contributor

    If you do not want to downgrade PHP or use an own fork of SendGrid, you can use a drop-in hack into their namespace as follows:

    Create a PHP file Curl.php somewhere:

    <?php
    
    namespace SendGrid;
    
    function curl_close($ch): void {
        if (is_resource($ch)) {
            unset($ch);
        }
    }
    

    Import this file BEFORE the autoload/ClassLoader system, for example in your custom autoload.php:

    <?php
    
    use Composer\Autoload\ClassLoader;
    
    require __DIR__ . '/Compat/SendGrid/Curl.php'; // TODO: temporary fix
    
    require_once __DIR__ . '/../vendor/autoload.php';
    
    $classLoader = new ClassLoader();
    $classLoader->addPsr4("YourProject\\", __DIR__, true);
    $classLoader->register();
    

    This works because SendGrid is not using \curl_close, but curl_close in their files.

  4. esetnik commented on Jun 18, 2026

    @esetnik
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions