New PSR for providing PDO connections (PdoProviderInterface)#1348
New PSR for providing PDO connections (PdoProviderInterface)#1348maximegosselin wants to merge 1 commit intophp-fig:masterfrom
Conversation
|
Hi @maximegosselin, thank you for drafting your proposal. To make this go further, I suggest you to look at our PSR workflow, which this proposal should follow. I would suggest to reach out to whomever should adopt this interface (i.e. Doctrine) to have them onboard, which would raise the probability of this being accepted. I'll switch this to draft for now. |
|
Does it have to be bound to PDO? |
Could you please elaborate? I'm not sure what "bound to PDO" means in this context. Are you suggesting the interface should return a more generic type, or something else entirely? |
|
I'm not really sure I see the benefit here as stated. In general, a library that consumes a PDO connection can already be interoperable by simply accepting the connection itself via DI. Can you be more specific about why hinting on something like |
|
To provide supporting evidence for this proposal, I've put together a research repository that demonstrates how 10 popular PHP database libraries handle PDO connections in practice: https://github.com/maximegosselin/pdo-provider-research It covers three scenarios for each library:
The consistent pattern across library types supports the case for a standard Libraries covered:
|
@KorvinSzanto That's a fair point. Accepting A concrete example: Doctrine DBAL has lazy connection support built in. With a standard |
|
@maximegosselin Please keep the discussion on the list, not in the PR. That way there's only one place folks need to follow. |
There is no standard contract for passing a PDO connection between libraries, and passing
\PDOdirectly surrenders control over the connection lifecycle.Goal
Provide a minimal interface that decouples PDO connection consumption from connection lifecycle management, and enables interoperability between libraries that need a connection and those that manage one.
Background
https://maximegosselin.com/posts/proposing-a-psr-for-pdo-providers/