juanvladimir13 / postgres-database
Conexion native to postgres
Package info
github.com/juanvladimir13/postgres-database
pkg:composer/juanvladimir13/postgres-database
v0.1.7
2026-06-09 13:23 UTC
Requires
- php: ^7.4|^8.3
- ext-pgsql: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.45
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.8
- vimeo/psalm: ^5.18
README
A lightweight native PHP package for interacting with PostgreSQL databases. It provides a simple connection wrapper, an environment variable loader, and an Active Record-style base model for building data-driven applications with minimal overhead.
Features
- Environment Configuration: A minimal
Dotenvclass to securely load database credentials (DB_HOST,DB_PORT,DB_DATABASE,DB_USERNAME,DB_PASSWORD) from.envfiles. - PostgreSQL Connection Wrapper: The
Postgresclass provides static methods to easily execute queries and performinsert,update,delete, andfetchAlloperations using associative arrays. - Active Record Base Model: An abstract
Modelclass that simplifies CRUD operations, supporting soft deletes, state management (EDITABLE), and standardized response formats. - Data Type Casting: Built-in support for mapping request payloads to specific data types (int, float, string, boolean, utf-8, etc.) using the
DataTypeconstants.
Directory Structure (src/)
Dotenv.php: Loads database connection settings and generates the PostgreSQL connection string.Postgres.php: Core singleton wrapper over native PHPpg_*functions.Models/Model.php: Abstract class providing high-level data access methods (likesave,find,findAll,delete,restore) to be inherited by your application's entities.Models/DataType.php: Defines constants for data types used in request data extraction and casting.