Why PHP?
PHP has been relevant for over three decades and was designed specifically for server-side web development.
That means:
- Native handling of
$_GET,$_POST,$_SESSION - Built-in cookie support
- Easy header redirects
- Seamless HTML embedding
1. Extremely Easy to Deploy
PHP runs almost everywhere:
- Apache
- Nginx
- IIS (using FastCGI)
- Shared hosting
- VPS
- Local XAMPP/WAMP setups
- You do not need:
- A runtime server like Node
- A compiler
- A special hosting platform
That simplicity is powerful.
2. Excellent Database Integration
For a blog app like mine, this is huge.
PHP + MySQL is a classic combination.
With PDO
PHP provides excellent integration with databases such as MySQL/MariaDB, PostgreSQL, and SQLite. Using PDO gives a modern and secure way to work with database queries and CRUD operations.
$stmt = $db->prepare("SELECT * FROM users WHERE email = :email");
$stmt->execute(['email' => $email]);
$user = $stmt->fetch();
Example: Database Portability in a Small MVC Framework
One thing I appreciate about PHP and PDO is how a small custom framework can keep the same overall
database structure while adapting to different database systems. In my project, the connection class
is centered around a simple Core/Database.php design. That same pattern can be reused
with other PDO drivers by changing the DSN.
For example, instead of connecting with PDO_MYSQL, a framework could also connect
through PDO_ODBC using an installed ODBC driver.
<?php
namespace App\Core;
use PDO;
use PDOException;
class Database
{
private static ?PDO $instance = null;
public static function connect(): PDO
{
if (self::$instance === null) {
$dsn = "odbc:Driver={ODBC Driver 17 for SQL Server};Server=localhost;Database=myblog_db;";
try {
self::$instance = new PDO($dsn, '', '', [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
]);
} catch (PDOException $e) {
die("Database connection failed: " . $e->getMessage());
}
}
return self::$instance;
}
}
In this example, the framework structure does not really change. The main difference is the DSN, which now points to an ODBC driver instead of a native MySQL connection. That flexibility shows how a small PHP framework can remain simple while still being portable across different database systems.
Here are some of the databases PHP's PDO can connect to, classified by their respective PDO drivers:
- MySQL & MariaDB:
PDO_MYSQL - PostgreSQL:
PDO_PGSQL - SQLite:
PDO_SQLITE - Microsoft SQL Server & Sybase:
PDO_DBLIBorPDO_SQLSRV - Oracle:
PDO_OCI - Firebird:
PDO_FIREBIRD - IBM DB2:
PDO_IBM - Informix:
PDO_INFORMIX - ODBC v3:
PDO_ODBC - CUBRID:
PDO_CUBRID - 4D:
PDO_4D - FreeTDS:
PDO_DBLIB
Key Benefits of PDO Connections
- Unified API: similar PHP methods across supported databases
- Portability: easier to switch systems through the DSN
- Security: prepared statements help prevent SQL injection
To check which drivers are available in your PHP installation, you can use
print_r(PDO::getAvailableDrivers());