Webrium

FoxDB PHP ORM Library

FoxDB is a modern library for database communication and management that is used in the Webrium framework but can be installed and used independently on any other project.

FoxDB image


This library is simple to use and is largely similar to the methods used in Laravel, but it has been tried to be close to the structure of the SQL language.



To install with Composer:

composer require webrium\foxdb



And before using it, we need to configure it so that it can connect to the database


Add Connection Config

use Foxdb\DB;
use Foxdb\Config;

DB::addConnection('main', [
'host'=>'localhost',
'port'=>'3306',

'database'=>'test',
'username'=>'root',
'password'=>'1234',

'charset'=>Config::UTF8,
'collation'=>Config::UTF8_GENERAL_CI,
'fetch'=>Config::FETCH_CLASS
]);



So now everything is ready to use.

Everything is kept close to the SQL language to make it easy to learn


For example, to run a query like this:


$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "SELECT `id`, `image`, `name` FROM users WHERE role = 'admin'";
$stmt = $conn->query($sql);
$user = $stmt->fetchAll(PDO::FETCH_ASSOC);


Using FoxDB we do this:

$users = DB::table('users')->select('id', 'image', 'name')->where('role', 'admin')->get();


It's simpler and cleaner, right?



Advantages of using FoxDB:

  1. More readable and understandable code
  2. Easier to make changes
  3. Ability to create complex queries
  4. Increased security
  5. Better integration with PHP code


View repository and documentation

© 2025 Webrium. All rights reserved.