Installation guide for the PDOdb library.
- PHP: 8.4 or higher
- PDO Extensions:
pdo_mysqlfor MySQL/MariaDBpdo_pgsqlfor PostgreSQLpdo_sqlitefor SQLite
- Supported Databases:
- MySQL 5.7+ / MariaDB 10.3+
- PostgreSQL 9.4+
- SQLite 3.38+
composer require tommyknocker/pdo-database-class# Latest 2.x version
composer require tommyknocker/pdo-database-class:^2.0
# Latest 1.x version (legacy)
composer require tommyknocker/pdo-database-class:^1.0
# Development version
composer require tommyknocker/pdo-database-class:dev-masterAfter installation, you can verify it by creating a simple test file:
<?php
require 'vendor/autoload.php';
use tommyknocker\pdodb\PdoDb;
// Test SQLite connection (no setup required)
$db = new PdoDb('sqlite', [
'path' => ':memory:'
]);
echo "PDOdb installed successfully!\n";Run the test:
php test-installation.phpBefore proceeding, verify that the required PDO extensions are installed:
php -m | grep pdoYou should see:
pdo_mysql(for MySQL)pdo_pgsql(for PostgreSQL)pdo_sqlite(for SQLite)
# MySQL
sudo apt-get install php8.4-mysql
# PostgreSQL
sudo apt-get install php8.4-pgsql
# SQLite
sudo apt-get install php8.4-sqlite3# Using Homebrew
brew install php# MySQL
sudo yum install php-mysql
# PostgreSQL
sudo yum install php-pgsql
# SQLite
sudo yum install php-sqlite3SQLite needs to be compiled with JSON support:
sqlite3 :memory: "SELECT json_valid('{}')"If this returns 1, JSON support is enabled. If it returns an error, you need to use a different SQLite build or recompile SQLite with JSON support.
- Configuration - Configure your database connection
- First Connection - Make your first connection
- Hello World - Build your first query