catfan/medoo

The lightweight PHP database framework to accelerate development

Installs: 1 292 234

Dependents: 255

Suggesters: 4

Security: 1

Stars: 4 870

Watchers: 209

Forks: 1 148

Open Issues: 53

Type:framework

v2.2.0 2025-03-31 07:37 UTC

README

Build Status Total Downloads Latest Stable Version License Backers on Open Collective Sponsors on Open Collective

The lightweight PHP database framework to accelerate development.

Features

  • Lightweight - Single-file framework with minimal dependencies.

  • Easy - Simple and intuitive API for quick integration.

  • Powerful - Supports complex SQL queries, data mapping, and SQL injection prevention.

  • Compatible - Works with MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, Oracle, Sybase, and more.

  • Friendly - Integrates seamlessly with Laravel, CodeIgniter, Yii, Slim, and other PHP frameworks.

  • Free - Licensed under MIT, free to use for any purpose.

Requirements

  • PHP 7.3 or later
  • PDO extension enabled

Get Started

Install via composer

Add Medoo to the composer.json configuration file.

$ composer require catfan/medoo

Then update Composer

$ composer update
// Require Composer's autoloader
require 'vendor/autoload.php';

// Import Medoo namespace
use Medoo\Medoo;

// Initialize database connection
$database = new Medoo([
    'type' => 'mysql',
    'host' => 'localhost',
    'database' => 'name',
    'username' => 'your_username',
    'password' => 'your_password'
]);

// Insert data
$database->insert('account', [
    'user_name' => 'foo',
    'email' => 'foo@bar.com'
]);

// Retrieve data
$data = $database->select('account', [
    'user_name',
    'email'
], [
    'user_id' => 50
]);

echo json_encode($data);

// [{
//    "user_name" : "foo",
//    "email" : "foo@bar.com",
// }]

Contribution Guidelines

Before submitting a pull request, ensure compatibility with multiple database engines and include unit tests when possible.

Testing & Code Style

  • Run phpunit tests to execute unit tests.
  • Use php-cs-fixer fix to enforce code style consistency.

Commit Message Format

Each commit should begin with a tag indicating the type of change:

  • [fix] for bug fixes
  • [feature] for new features
  • [update] for improvements

Keep contributions simple and well-documented.

License

Medoo is released under the MIT License.

Links

Support Our Other Product

Gear Browser - Web Browser for Geek

Gear Browser