How to fix Symfony HttpClient error Undefined constant "CURL_SSLVERSION_TLSv1_2"

How to fix Symfony HttpClient error Undefined constant "CURL_SSLVERSION_TLSv1_2" banner

If you get the following error Undefined constant "CURL_SSLVERSION_TLSv1_2" in your Symfony application, you most probably have an outdated cURL PHP extension.

{
    "class": "Error",
    "message": "Undefined constant \"CURL_SSLVERSION_TLSv1_2\"",
    "code": 0,
    "file": "/www/sites/../vendor/symfony/http-client/CurlHttpClient.php:125",
    "trace": [
        "/www/sites/../vendor/symfony/http-client/ScopingHttpClient.php:88",
        "/www/sites/../vendor/symfony/http-client/UriTemplateHttpClient.php:47",
....

This error means that PHP is looking for CURL_SSLVERSION_TLSv1_2 constant, but it's not existing. This is because this constant was introduced in PHP cURL version 7.34.0 – on December 17, 2013.

To fix this error, you need to update your PHP cURL extension to version 7.34.0 or newer.

So if you have an older version, it won't work. You can check your version with phpinfo(), search for cURL.