Medoo Documentation

The lightweight PHP database framework to accelerate the development.

RAW Doc

File: README.md

The lightweight PHP database framework to accelerate development.

Documentation

Features

  • Lightweight - A lightweight single-file package that keeps dependencies to a minimum.

  • Easy - A clean, intuitive API that helps you get started quickly.

  • Powerful - Designed for complex SQL, data mapping, and prepared statements without sacrificing readability.

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

  • Friendly - Fits naturally into Laravel, CodeIgniter, Yii, Slim, and other PHP frameworks.

  • Free - Released under the MIT license and free to use in personal or commercial projects.

Requirements

  • PHP 7.3 or later
  • PDO extension enabled

Get Started

Install via composer

Add Medoo to the composer.json configuration file.

bash
$ composer require catfan/medoo

Then update Composer

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

// Import the Medoo namespace.
use Medoo\Medoo;

// Create a 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' => '[email protected]'
]);

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

echo json_encode($data);

// [{
//    "user_name" : "foo",
//    "email" : "[email protected]",
// }]

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.

[More Products We Build]

Gear Browser - AI Extension Web Browser


File: composer.json

{
"name": "catfan/medoo",
"type": "framework",
"description": "The lightweight PHP database framework to accelerate development",
"keywords": ["database", "database library", "lightweight", "PHP framework", "SQL", "MySQL", "MSSQL", "SQLite", "PostgreSQL", "MariaDB", "Oracle"],
"homepage": "https://medoo.in",
"license": "MIT",
"support": {
"issues": "https://github.com/catfan/Medoo/issues",
"source": "https://github.com/catfan/Medoo"
},
"authors": [
{"name": "Angel Lai", "email": "[email protected]"}
],
"require": {
"php": ">=7.3",
"ext-pdo": "*"
},
"require-dev": {
"phpunit/phpunit": "^13",
"phpstan/phpstan": "^2.2"
},
"suggest": {
"ext-pdo_mysql": "For MySQL or MariaDB database",
"ext-pdo_sqlsrv": "For MSSQL database on both Window/Liunx platform",
"ext-pdo_dblib": "For MSSQL or Sybase database on Linux/UNIX platform",
"ext-pdo_oci": "For Oracle database",
"ext-pdo_pqsql": "For PostgreSQL database",
"ext-pdo_sqlite": "For SQLite database"
},
"autoload": {
"psr-4": {
"Medoo\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Medoo\Tests\": "tests/"
}
},
"scripts": {
"phpstan": [
"@phpstan:src",
"@phpstan:tests"
],
"phpstan:src": "phpstan analyse --no-progress",
"phpstan:tests": "phpstan analyse --configuration=phpstan-tests.neon.dist --no-progress",
"test": "vendor/bin/phpunit tests"
}
}


File: LICENSE.md

MIT License

Copyright (c) 2026 Angel Lai

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


File: .github/FUNDING.yml

These are supported funding model platforms

open_collective: medoo
custom: ["https://paypal.me/AngelaonLai"]


File: .github/ISSUE_TEMPLATE/bug_report.md


name: Bug report about: Create a report to help us improve

Information

  • Version of Medoo: [Enter the version number]
  • Version of PHP: [Enter the version number]
  • Type of Database: [MySQL, MSSQL, SQLite, etc.]
  • System: [Linux|Windows|Mac]

Describe the Problem
A clear and concise description of what the problem is.

Code Snippet
The detail code you are using that causes the problem:

php
// Write your PHP code here

Expected Behavior
A clear and concise description of what you expected to happen.

Actual Behavior
A clear and concise description of what actually happened.


File: .github/workflows/php.yml

name: build

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest

text
strategy:
  fail-fast: false
  matrix:
    php: ['8.4', '8.5']

steps:
- uses: actions/checkout@v4

- name: Setup PHP
  uses: shivammathur/setup-php@v2
  with:
    php-version: ${{ matrix.php }}
    tools: composer:v2
    coverage: none

- name: Validate composer.json
  run: composer validate --strict --no-check-lock

- name: Cache dependencies
  uses: actions/cache@v4
  with:
    path: vendor
    key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json', 'composer.lock') }}
    restore-keys: |
      ${{ runner.os }}-php-${{ matrix.php }}-composer-

- name: Install dependencies
  run: composer install --prefer-dist --no-interaction --no-progress

- name: Run static analysis
  run: composer phpstan

- name: Run test suite
  run: composer run-script test