Skip to content

Latest commit

 

History

History
124 lines (85 loc) · 2.17 KB

File metadata and controls

124 lines (85 loc) · 2.17 KB

Installation

Installation guide for the PDOdb library.

Requirements

  • PHP: 8.4 or higher
  • PDO Extensions:
    • pdo_mysql for MySQL/MariaDB
    • pdo_pgsql for PostgreSQL
    • pdo_sqlite for SQLite
  • Supported Databases:
    • MySQL 5.7+ / MariaDB 10.3+
    • PostgreSQL 9.4+
    • SQLite 3.38+

Installing via Composer

Latest Version

composer require tommyknocker/pdo-database-class

Specific Versions

# 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-master

Verifying Installation

After 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.php

Checking PDO Extensions

Before proceeding, verify that the required PDO extensions are installed:

php -m | grep pdo

You should see:

  • pdo_mysql (for MySQL)
  • pdo_pgsql (for PostgreSQL)
  • pdo_sqlite (for SQLite)

Installing PDO Extensions

Ubuntu/Debian

# MySQL
sudo apt-get install php8.4-mysql

# PostgreSQL
sudo apt-get install php8.4-pgsql

# SQLite
sudo apt-get install php8.4-sqlite3

macOS

# Using Homebrew
brew install php

CentOS/RHEL

# MySQL
sudo yum install php-mysql

# PostgreSQL
sudo yum install php-pgsql

# SQLite
sudo yum install php-sqlite3

Verifying SQLite JSON Support

SQLite 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.

Next Steps