progrmanial / simplemdb
Enterprise Database Toolkit for PHP - Modern schema management, intelligent migrations, and advanced query building
Requires
- php: >=8.0
- ext-json: *
- ext-mbstring: *
- ext-mysqli: *
- ext-pdo: *
- psr/event-dispatcher: ^1.0
- psr/log: ^3.0
Requires (Dev)
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.6
- vimeo/psalm: ^4.0
README
🚀 Production-Ready Database Management - Build enterprise-grade applications with Laravel-like syntax, 25+ data types, intelligent migrations, and military-grade security.
⚡ 5-Minute Quick Start
Install SimpleMDB:
composer require simplemdb/simplemdb
Create your first table:
<?php require_once 'vendor/autoload.php'; use SimpleMDB\DatabaseFactory; use SimpleMDB\SchemaBuilder; // Connect to database $db = DatabaseFactory::create('pdo', 'localhost', 'root', 'password', 'myapp'); // Create modern table with enterprise features $schema = new SchemaBuilder($db); $schema->increments('id') // Auto-increment primary key ->string('name', 100)->comment('Full name') // VARCHAR with comment ->string('email', 150)->unique() // Unique email ->boolean('is_active')->default(true) // Boolean with default ->json('preferences')->nullable() // JSON data storage ->ipAddress('last_login_ip')->nullable() // IPv4/IPv6 address ->timestamps() // created_at, updated_at ->createTable('users'); echo "✅ Modern users table created!\n";
That's it! You now have a production-ready table with modern data types and enterprise features.
👉 Try the complete quick start example →
🏆 Why Choose SimpleMDB?
Laravel-Like Developer Experience
// Familiar fluent syntax $users = SimpleQuery::create() ->select(['id', 'name', 'email']) ->from('users') ->where('is_active = ?', [true]) ->orderBy('created_at DESC') ->execute($db);
25+ Modern Data Types
$table->uuid('external_id') // UUID storage ->ipAddress('client_ip') // IPv4/IPv6 (45 chars) ->json('metadata') // JSON documents ->point('location') // Geographic coordinates ->morphs('commentable'); // Polymorphic relationships
Intelligent Migrations
// Auto-generates context-aware templates $migrations->create('create_blog_posts_table'); // ✨ Detects "blog posts" and generates complete table structure
Enterprise Security & Performance
- 100% SQL injection prevention with comprehensive validation
- Memory-efficient streaming for large datasets (10-50x reduction)
- AES-256 encryption for sensitive data
- Connection pooling and advanced caching
Complete Database Object Management
- Functions & Procedures with fluent parameter management
- Views with algorithm optimization and security contexts
- Events with flexible scheduling (one-time, recurring, intervals)
- Triggers for data integrity and automated auditing
- Unified Management interface for all database objects
📚 Documentation
🚀 Getting Started
- 5-Minute Quick Start - Get SimpleMDB working immediately
- Installation Guide - Detailed setup and configuration
- Basic Concepts - Core SimpleMDB concepts
- Testing Guide - Write reliable tests for your application
🏗️ Core Features
- Schema Builder - Create and modify database tables
- Data Types Reference - All 25+ data types with examples
- Query Builder - Advanced query building
- Migration System - Intelligent database migrations
🔄 Migration Guides
- From Laravel/Eloquent - Migrate from Laravel
- From Doctrine ORM - Migrate from Doctrine
- From CodeIgniter - Migrate from CodeIgniter
- Complete Migration Guide - All framework migrations
🛡️ Enterprise Features
- Security Guide - Enterprise security best practices
- Performance Optimization - Caching, pooling, optimization
- Backup System - Complete backup and restore solution
- Database Objects - Functions, procedures, views, events, triggers
- Testing Guide - Testing your SimpleMDB applications
🔄 Migration Guides
- From Laravel - Step-by-step Laravel migration
- From Doctrine - Doctrine to SimpleMDB
- From Raw SQL - Converting raw SQL projects
🎯 Feature Comparison
Feature | SimpleMDB | Laravel Schema | Doctrine DBAL |
---|---|---|---|
Data Types | ✅ 25+ types | ✅ 27+ types | ✅ 20+ types |
Schema Validation | ✅ Comprehensive | ⚠️ Basic | ⚠️ Basic |
Migration Intelligence | ✅ Smart Templates | ⚠️ Static | ❌ Manual |
Database Objects | ✅ Complete | ❌ Limited | ❌ Limited |
Security Features | ✅ Enterprise | ✅ Good | ✅ Good |
Memory Efficiency | ✅ Streaming | ⚠️ Standard | ⚠️ Standard |
Learning Curve | ✅ Gentle | ⚠️ Steep | ⚠️ Steep |
💡 Real-World Examples
E-commerce Product Table
$schema->createTable('products', function($table) { $table->increments('id'); $table->string('sku', 50)->unique(); $table->string('name', 200); $table->decimal('price', 10, 2)->unsigned(); $table->json('attributes')->nullable(); // Color, size, etc. $table->enum('status', ['draft', 'published'])->default('draft'); $table->ipAddress('created_from_ip'); $table->timestamps(); $table->index(['status', 'price']); });
User Authentication System
$schema->createTable('users', function($table) { $table->increments('id'); $table->string('email')->unique(); $table->string('password'); $table->json('preferences')->nullable(); $table->ipAddress('last_login_ip')->nullable(); $table->timestamp('email_verified_at')->nullable(); $table->rememberToken(); $table->timestamps(); $table->softDeletes(); });
Complete Backup Solution
use SimpleMDB\Backup\BackupManager; $backupManager = new BackupManager($db, 'backups/'); // Memory-efficient encrypted backup $backup = $backupManager ->backup('daily_backup') ->streaming(1000) // Process in chunks ->encrypted($encryptionKey) // AES-256 encryption ->compress('gzip') // Space efficient ->execute();
Database Objects Management
use SimpleMDB\DatabaseObjects\DatabaseObjectManager; $objects = new DatabaseObjectManager($db); // Create a function $objects->function('calculate_total') ->inParameter('amount', 'DECIMAL(10,2)') ->returns('DECIMAL(10,2)') ->body("RETURN amount * 1.1;") ->create(); // Create a view with complex logic $objects->view('user_summary') ->select(" u.id, u.name, u.email, COUNT(o.id) as order_count, SUM(o.total) as total_spent FROM users u LEFT JOIN orders o ON u.id = o.user_id GROUP BY u.id ") ->create(); // Create a trigger for auditing $objects->trigger('audit_changes') ->after() ->update() ->on('users') ->body("INSERT INTO audit_log (table_name, action, record_id) VALUES ('users', 'UPDATE', NEW.id);") ->create();
⚙️ System Requirements
- PHP: 8.0 or higher
- MySQL: 5.7+ or 8.0+ (recommended)
- MariaDB: 10.2+ (fully supported)
- Extensions: PDO or MySQLi (at least one required)
- Memory: 64MB minimum (128MB recommended)
🚀 Installation Options
Composer (Recommended)
composer require simplemdb/simplemdb
Manual Installation
git clone https://github.com/imrnansaadullah/SimpleMDB.git
cd SimpleMDB
composer install
Verify Installation
<?php require_once 'vendor/autoload.php'; use SimpleMDB\DatabaseFactory; try { $db = DatabaseFactory::create('pdo', 'localhost', 'root', 'password', 'test'); echo "✅ SimpleMDB installed successfully!\n"; } catch (Exception $e) { echo "❌ Installation issue: " . $e->getMessage() . "\n"; }
🎓 Learning Path
Beginner (30 minutes)
- 5-Minute Quick Start - Basic table creation
- Schema Builder Basics - Understanding column types
- Simple Queries - SELECT, INSERT, UPDATE, DELETE
Intermediate (2 hours)
- Advanced Data Types - JSON, UUIDs, polymorphic types
- Migration System - Creating and running migrations
- Security Best Practices - SQL injection prevention
Advanced (1 day)
- Performance Optimization - Caching, connection pooling
- Enterprise Backup System - Complete backup solutions
- Production Deployment - Production best practices
🛠️ Quick API Reference
Schema Builder
// Column types $table->string('name', 100) // VARCHAR $table->integer('count') // INT $table->boolean('active') // TINYINT(1) $table->json('data') // JSON $table->timestamp('created_at') // TIMESTAMP $table->ipAddress('ip') // VARCHAR(45) // Modifiers $table->nullable() // Allow NULL $table->default('value') // Default value $table->unique() // Unique constraint $table->comment('Description') // Column comment // Indexes $table->index(['column']) // Regular index $table->unique(['email']) // Unique index $table->foreignKey('user_id', 'users', 'id') // Foreign key
Query Builder
// SELECT $users = SimpleQuery::create() ->select(['id', 'name', 'email']) ->from('users') ->where('active = ?', [true]) ->execute($db); // INSERT $result = SimpleQuery::create() ->insert(['name' => 'John', 'email' => 'john@example.com']) ->into('users') ->execute($db); // UPDATE $result = SimpleQuery::create() ->update('users') ->set(['name' => 'Jane']) ->where('id = ?', [1]) ->execute($db);
🤝 Contributing
We welcome contributions! See our Contributing Guide for details.
Quick Contribution Setup
git clone https://github.com/imrnansaadullah/SimpleMDB.git cd SimpleMDB composer install php examples/quick_start_example.php # Test your setup
📖 Resources
- Complete Documentation - Comprehensive guides and references
- Example Projects - Real-world usage examples
- API Reference - Complete method documentation
- Video Tutorials - Step-by-step video guides
- Community Forum - Get help and share tips
📜 License
MIT License - Use SimpleMDB in any project, commercial or open source.
🌟 Enterprise Ready
SimpleMDB is production-ready for enterprise applications. Join the growing community of developers who choose SimpleMDB for its combination of power, security, and developer experience.
⭐ Star us on GitHub if SimpleMDB helps you build better applications!
Need enterprise support? [Contact us](mailto:lems? @simplemdb.com) for professional services, training, and custom development.