Skip to content

[11.x] Fix PHP 8.5 deprecation warning for PDO::MYSQL_ATTR_SSL_CA#539

Open
emmadesilva wants to merge 1 commit into
laravel-zero:11.xfrom
emmadesilva:patch-1
Open

[11.x] Fix PHP 8.5 deprecation warning for PDO::MYSQL_ATTR_SSL_CA#539
emmadesilva wants to merge 1 commit into
laravel-zero:11.xfrom
emmadesilva:patch-1

Conversation

@emmadesilva

@emmadesilva emmadesilva commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Description

This PR patches a deprecation warning triggered when using PHP 8.5 with Laravel Zero 11.x.

I understand that Laravel Zero 11 may not be officially supported anymore, but since a lot of projects are still running it, this minor patch would provide a lot of value with minimal downside.

See tie in PR laravel-zero/foundation#133

Background:
In PHP 8.5, the global PDO::MYSQL_ATTR_SSL_CA constant was deprecated in favor of the namespaced Pdo\Mysql::ATTR_SSL_CA. However, because Laravel Zero 11.x must maintain compatibility with PHP 8.2 and 8.3 (where the Pdo\Mysql class does not exist), we cannot simply swap the constant without causing a fatal error in older environments.

The Fix:
This PR updates the MySQL and MariaDB connection configurations to use a conditional check:
(defined('Pdo\Mysql::ATTR_SSL_CA') ? Pdo\Mysql::ATTR_SSL_CA : PDO::MYSQL_ATTR_SSL_CA)

This dynamically applies the new constant for users on PHP 8.5+, while safely falling back to the legacy constant for users on PHP 8.2 - 8.4, completely resolving the deprecation notice without introducing breaking changes.

Related Issues

Checklist

  • I have tested this change locally to ensure compatibility across PHP versions.
  • The code follows the repository's coding standards.

@owenvoke owenvoke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This makes sense to me. 👍🏻

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants