Download the PHP package gemvc/connection-contracts without Composer
On this page you can find all versions of the php package gemvc/connection-contracts. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gemvc/connection-contracts
More information about gemvc/connection-contracts
Files in gemvc/connection-contracts
Package connection-contracts
Short Description Database connection contracts for GEMVC framework
License MIT
Homepage https://github.com/gemvc/connection-contracts
Informations about the package connection-contracts
gemvc/connection-contracts
Database connection contracts for GEMVC framework.
Package Information
- Package Name:
gemvc/connection-contracts - Namespace:
Gemvc\Database\Connection\Contracts\ - Type: Contracts/Interfaces only (no implementation)
Purpose
This package defines the contracts (interfaces) for database connection management across different drivers (PDO, Swoole/Hyperf, MongoDB, etc.).
Contents
Interfaces
ConnectionInterface- Contract for individual database connectionsConnectionManagerInterface- Contract for connection pool/manager
Exceptions
ConnectionException- Base exception for connection errorsConnectionFailedException- Connection failure exceptionTransactionException- Transaction-related exception
Utilities
ConnectionManagerAdapter- Framework-agnostic adapter for wrapping legacy managersConnectionManagerFactory- Factory for creating connection managers from legacy implementations
Installation
Usage
Key Design Decisions
Return Type: ?object
The ConnectionInterface::getConnection() method returns ?object (not mixed) for:
- Better type safety
- PHPStan Level 9 compliance
- Future extensibility (supports PDO, MongoDB, etc.)
Transaction Methods
Transaction methods (beginTransaction, commit, rollback, inTransaction) are defined in ConnectionInterface, NOT in ConnectionManagerInterface.
Rationale: Single Responsibility Principle (SRP) and Dependency Inversion Principle (DIP)
- Manager manages pool lifecycle
- Connection executes operations
Requirements
- PHP >= 8.1
Status
✅ Stable - Version 1.0.0
This package is production-ready and follows SOLID principles with PHPStan Level 9 compliance.
Architecture
This package implements a clean separation of concerns:
- ConnectionManagerInterface: Manages connection pool lifecycle (get/release connections)
- ConnectionInterface: Handles connection operations (queries, transactions)
- Exceptions: Comprehensive exception hierarchy for error handling
This design follows:
- Single Responsibility Principle (SRP): Manager handles pools, Connection handles operations
- Dependency Inversion Principle (DIP): Depend on abstractions, not concretions
Contributing
Contributions are welcome! Please ensure all code:
- Passes PHPStan Level 9 analysis
- Includes unit and integration tests
- Follows PSR-12 coding standards
License
MIT License - see LICENSE file for details