PHPackages                             dynamiccrud/dynamiccrud - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. dynamiccrud/dynamiccrud

ActiveLibrary[Database &amp; ORM](/categories/database)

dynamiccrud/dynamiccrud
=======================

PHP library for generating dynamic CRUD forms with automatic validation based on database structure

3.5.0(6mo ago)02[2 PRs](https://github.com/trymorpheus/morpheus/pulls)MITPHPPHP &gt;=8.0CI passing

Since Nov 1Pushed 4mo agoCompare

[ Source](https://github.com/trymorpheus/morpheus)[ Packagist](https://packagist.org/packages/dynamiccrud/dynamiccrud)[ Docs](https://github.com/mcarbonell/DynamicCRUD)[ RSS](/packages/dynamiccrud-dynamiccrud/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (1)Versions (7)Used By (0)

Morpheus
========

[](#morpheus)

[![Tests](https://github.com/trymorpheus/morpheus/workflows/Tests/badge.svg)](https://github.com/trymorpheus/morpheus/actions)[![Code Quality](https://github.com/trymorpheus/morpheus/workflows/Code%20Quality/badge.svg)](https://github.com/trymorpheus/morpheus/actions)[![Packagist Version](https://camo.githubusercontent.com/ed3a31a1c2e0a90014c981310c2dd6c4e5ed21d86f095387f5170ef6ed81da68/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7472796d6f7270686575732f6d6f727068657573)](https://packagist.org/packages/trymorpheus/morpheus)[![PHP Version](https://camo.githubusercontent.com/d8dc3405b087b629a931e9d13cc1e414a32958b3f6704df918dd0fbf14f76485/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7472796d6f7270686575732f6d6f727068657573)](https://packagist.org/packages/trymorpheus/morpheus)[![License](https://camo.githubusercontent.com/4401f99aa2c0204abb52c83f147b4e08688f6edecf9e3407b63b067199ed6dd9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d636172626f6e656c6c2f44796e616d696343525544)](https://github.com/trymorpheus/morpheus/blob/main/LICENSE)[![Downloads](https://camo.githubusercontent.com/61d6ed9fb1b924828ca0f70fa78fd63a3707655778efffdc79af7a93079def26/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7472796d6f7270686575732f6d6f727068657573)](https://packagist.org/packages/trymorpheus/morpheus)

**The Universal CMS - Start as a blog, grow into anything.**

Morpheus is the world's first **Universal CMS** that combines the simplicity of WordPress with the power of a custom application generator. Start with a blog in 60 seconds, then grow into e-commerce, CRM, or any custom application - all without migrations, plugins, or code.

**🎯 Perfect for:**

- 📝 Bloggers seeking a faster WordPress alternative
- 🏢 Businesses needing a website that grows with them
- 👨‍💻 Developers building client sites rapidly
- 🚀 Startups prototyping MVPs in minutes

[🇪🇸 Documentación en Español](README.es.md) | [📖 Universal CMS Vision](UNIVERSAL_CMS.md) | [🗺️ Complete Roadmap](ROADMAP.md)

---

✨ Features
----------

[](#-features)

### 🚀 Core

[](#-core)

- **Zero-config form generation** from SQL schema
- **Automatic validation** (server + client-side JavaScript)
- **CSRF protection** built-in
- **SQL injection prevention** with prepared statements
- **Smart NULL handling** for nullable fields
- **File uploads** with MIME type validation

### 🔗 Relationships

[](#-relationships)

- **Foreign keys auto-detection** with dropdown selects
- **Many-to-many relationships** with multi-select
- **Custom display columns** for related data

### ⚡ Advanced

[](#-advanced)

- **CLI Tool** - Command-line interface for project management
- **Authentication** - Register, login, logout with rate limiting
- **RBAC** - Role-based access control with row-level security
- **Soft Deletes** - Mark records as deleted, restore or permanently delete
- **Multi-database support** (MySQL, PostgreSQL)
- **Internationalization (i18n)** - 3 languages included (EN, ES, FR)
- **Template System** - Blade-like syntax for custom layouts
- **Hooks/Events system** (10 lifecycle hooks)
- **Virtual fields** (password confirmation, terms acceptance)
- **Automatic transactions** with rollback on error
- **Audit logging** for change tracking
- **Caching system** for schema metadata
- **ENUM field support** with auto-generated selects
- **Accessibility** (ARIA labels, keyboard navigation)

---

📦 Installation
--------------

[](#-installation)

```
composer require trymorpheus/morpheus
```

**Requirements:** PHP 8.0+, MySQL 5.7+ or PostgreSQL 12+, PDO extension

### CLI Tool

[](#cli-tool)

After installation, initialize your project:

```
php bin/morpheus init
php bin/morpheus list:tables
php bin/morpheus generate:metadata users
```

---

✨ What's New in v4.0 (IN PROGRESS)
----------------------------------

[](#-whats-new-in-v40-in-progress)

**Universal CMS Foundation** - First working WordPress alternative with Blog CMS!

**Blog Content Type:**

- Complete WordPress-style blog with posts, categories, tags, and comments
- Frontend rendering with clean URLs and SEO optimization
- Admin panel with sidebar navigation and CRUD operations
- Automatic sitemap.xml and RSS feed generation
- Table prefixes for example isolation (e.g., `24_posts`, `24_categories`)

**Theme System:**

- 3 built-in themes (Minimal, Modern, Classic)
- Hot theme switching without data loss
- Self-contained themes with templates and styles
- Pluggable architecture for custom themes
- Database-persisted active theme

**One-Click Installer:**

- WordPress-style installation wizard (8 steps)
- Beautiful responsive web UI
- CLI mode (interactive + non-interactive)
- System requirements check
- Database connection testing
- Content type selection (blog/empty)
- Theme selection with previews
- Automatic config file generation

**Media Library:**

- Complete file management system
- Multiple file upload with drag &amp; drop
- Folder organization and navigation
- Grid view with thumbnails
- Image editing (resize, crop, thumbnails)
- Search and filter functionality
- File statistics and storage tracking

**Comment System:**

- Nested replies (up to 3 levels)
- Moderation (approve/reject/delete)
- Spam detection (keywords and links)
- Gravatar integration
- Beautiful responsive UI

```
use Morpheus\ContentTypes\ContentTypeManager;

$manager = new ContentTypeManager($pdo);
$manager->install('blog'); // Installs 5 tables with full metadata

// Frontend (index.php)
$router = new FrontendRouter();
$renderer = new FrontendRenderer($pdo, 'blog', null, $seo);
echo $renderer->renderHome(); // Beautiful blog homepage

// Admin (admin.php)
$admin = new AdminPanel($pdo);
$admin->addTable('posts', ['icon' => '📝']);
echo $admin->render(); // Full admin panel
```

**New Classes:**

- `ContentType` interface - Contract for all content types
- `ContentTypeManager` - Manages content type lifecycle
- `BlogContentType` - Complete blog implementation
- `FrontendRouter` - Routes public URLs to content
- `FrontendRenderer` - Renders public-facing pages
- `SEOManager` - Meta tags, Open Graph, Schema.org, sitemap, RSS
- `Theme` interface - Contract for all themes
- `ThemeManager` - Manages theme lifecycle
- `AbstractTheme` - Base class for themes
- `MinimalTheme`, `ModernTheme`, `ClassicTheme` - Built-in themes
- `SystemChecker` - Validates system requirements
- `DatabaseSetup` - Database connection and table creation
- `ConfigGenerator` - Generates config.php file
- `InstallerWizard` - Main installation orchestrator
- `MediaLibrary` - File upload and management
- `ImageEditor` - Image manipulation (resize, crop, thumbnails)
- `MediaBrowser` - Visual file browsing interface
- `CommentManager` - Comment CRUD and moderation
- `CommentRenderer` - Comment UI rendering

**Features:**

- 🎨 **Modern Design** - Professional frontend with navigation and search
- 🔍 **SEO Built-in** - Meta tags, Open Graph, Twitter Cards, Schema.org
- 📡 **RSS Feed** - Automatic RSS 2.0 feed generation
- 🗺️ **Sitemap** - XML sitemap with posts, categories, and tags
- 🚀 **Fast** - 20-30x faster than WordPress
- 🔐 **Secure** - No plugins = no vulnerabilities

👉 [See Blog CMS Example](examples/24-blog-cms/)
👉 [See Theme Showcase Example](examples/25-themes/)
👉 [See One-Click Installer Example](examples/27-installer/)
👉 [See Media Library Example](examples/28-media-library/)
👉 [See Comment System Example](examples/29-comments/)

---

✨ What's New in v3.5
--------------------

[](#-whats-new-in-v35)

**Core Classes Refactoring** - Massive improvements to code quality and maintainability!

**CRUDHandler Refactoring:**

- 88% reduction in main method (250 → 30 lines)
- Extracted 16 focused methods
- Fixed hook execution order
- Better error handling
- Single responsibility per method

**ValidationEngine Refactoring:**

- 13 extracted validation methods
- Type-specific validators
- Guard clauses for cleaner logic
- Consistent error handling
- Self-documenting code

**SchemaAnalyzer Refactoring:**

- Improved cache management
- Nullsafe operator for cleaner code
- 3 extracted cache methods
- Single source of truth

**Benefits:**

- ✅ Easier to understand and maintain
- ✅ Better testability
- ✅ Reduced cognitive load
- ✅ Consistent patterns
- ✅ All 366 tests passing (100%)

👉 [See Refactoring Patterns](docs/REFACTORING_PATTERNS.md)
👉 [See Release Notes](RELEASE_NOTES_v3.5.0.md)

---

✨ What's New in v3.4
--------------------

[](#-whats-new-in-v34)

**UI Classes Refactoring** - Improved code quality, maintainability, and Components integration!

**FormGenerator Refactoring:**

- Integrated Components library for tabs and buttons
- Simplified render() method from ~70 to ~15 lines
- Extracted 8 new methods for better organization
- CSS variables support for dynamic theming
- Eliminated code duplication

**ListGenerator Refactoring:**

- 20% code reduction (~350 to ~280 lines)
- Modern table styling with Components::table()
- Consistent pagination with Components::pagination()
- Cleaner action button rendering
- Better separation of concerns

👉 [See v3.4 Release Notes](RELEASE_NOTES_v3.4.0.md)

---

✨ What's New in v3.3
--------------------

[](#-whats-new-in-v33)

**UI Components Library** - 15 reusable, accessible, and beautiful components for building modern UIs!

```
use Morpheus\UI\Components;

// Set custom theme
Components::setTheme(['primary' => '#667eea']);

// Use components
echo Components::alert('Success!', 'success');
echo Components::badge('New', 'primary');
echo Components::button('Click Me', 'primary');
echo Components::card('Title', 'Content');
echo Components::modal('id', 'Title', 'Content');
echo Components::tabs([...]);
echo Components::table(['Name', 'Email'], [[...]]);
echo Components::pagination(3, 10);
```

**Features:**

- 🎨 **15 Components** - Alert, Badge, Button, Card, Modal, Tabs, Accordion, Table, and more
- 🎭 **Themeable** - Customize colors to match your brand
- ♿ **Accessible** - ARIA labels and keyboard navigation
- 📱 **Responsive** - Mobile-first design
- 🚀 **Zero Dependencies** - Pure PHP, no external libraries
- 💅 **Modern Design** - Clean, professional styling

👉 [See UI Components Example](examples/20-ui-components/)

---

✨ What's New in v3.2
--------------------

[](#-whats-new-in-v32)

**Workflow Engine** - State management with transitions, permissions, and history tracking!

```
$crud = new Morpheus($pdo, 'orders');

$crud->enableWorkflow([
    'field' => 'status',
    'states' => ['pending', 'processing', 'shipped', 'delivered'],
    'transitions' => [
        'process' => [
            'from' => 'pending',
            'to' => 'processing',
            'label' => 'Process Order',
            'permissions' => ['admin', 'manager']
        ],
        'ship' => [
            'from' => 'processing',
            'to' => 'shipped',
            'permissions' => ['admin', 'warehouse']
        ]
    ],
    'history' => true
]);

echo $crud->renderForm($id); // Automatic transition buttons!
```

**Features:**

- 🔄 **State Management** - Define allowed states for records
- ➡️ **Transitions** - Configure transitions between states
- 🔐 **Permission Control** - Restrict transitions by user role
- 🎨 **Automatic UI** - Transition buttons rendered automatically
- 📜 **History Tracking** - Complete audit trail of all transitions
- 🪝 **Lifecycle Hooks** - Execute custom logic before/after transitions
- 🏷️ **State Labels** - Custom labels and colors for each state

👉 [See Workflow Example](examples/19-workflow/)

---

✨ What's New in v3.1
--------------------

[](#-whats-new-in-v31)

**Admin Panel Generator** - Complete admin panel with navigation, dashboard, and integrated CRUD!

```
use Morpheus\Admin\AdminPanel;

$pdo = new PDO('mysql:host=localhost;dbname=test', 'user', 'pass');

$admin = new AdminPanel($pdo, [
    'title' => 'Mi Admin Panel',
    'theme' => [
        'primary' => '#667eea',
        'sidebar_bg' => '#2d3748',
        'sidebar_text' => '#e2e8f0'
    ]
]);

$admin->addTable('users', ['icon' => '👥', 'label' => 'Usuarios']);
$admin->addTable('products', ['icon' => '📦', 'label' => 'Productos']);
$admin->addTable('orders', ['icon' => '🛒', 'label' => 'Pedidos']);

echo $admin->render(); // Full admin panel!
```

**Features:**

- 📊 **Dashboard** - Automatic stats cards for all tables
- 🎨 **Sidebar Navigation** - Customizable menu with icons
- 🍞 **Breadcrumbs** - Contextual navigation
- 👤 **User Menu** - Avatar and user info
- 📱 **Responsive** - Mobile-first design
- 🔗 **Full Integration** - Uses Morpheus, ListGenerator, FormGenerator

👉 [See Admin Panel Example](examples/18-admin-panel/)

---

✨ What's New in v3.0
--------------------

[](#-whats-new-in-v30)

**REST API Generator** - Automatic REST API generation with JWT authentication!

```
use Morpheus\API\RestAPIGenerator;

$pdo = new PDO('mysql:host=localhost;dbname=test', 'user', 'pass');

// Create API instance
$api = new RestAPIGenerator($pdo, 'your-secret-key');
$api->handleRequest();

// That's it! All tables now have REST endpoints
```

```
# Login
curl -X POST http://localhost/api/v1/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"admin@example.com","password":"admin123"}'

# Get users (with token)
curl -X GET http://localhost/api/v1/users \
  -H "Authorization: Bearer YOUR_TOKEN"

# Create user
curl -X POST http://localhost/api/v1/users \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"John","email":"john@example.com"}'
```

**Features:**

- 🚀 **Auto Endpoints** - GET, POST, PUT, DELETE for every table
- 🔐 **JWT Authentication** - Secure token-based auth
- 📚 **OpenAPI/Swagger** - Auto-generated documentation
- 🌐 **CORS Ready** - Cross-origin requests enabled
- 📄 **Pagination** - Automatic list pagination
- 🔒 **RBAC Integration** - Optional permission control

👉 [See REST API Example](examples/17-rest-api/)

---

✨ What's New in v2.9
--------------------

[](#-whats-new-in-v29)

**Multiple File Upload &amp; Theme Integration** - Upload multiple files with drag &amp; drop + white-label theming!

```
// Multiple file upload with drag & drop UI
$crud = new Morpheus($pdo, 'properties');
echo $crud->renderForm(); // Automatic drag & drop for multiple_files type

// Enable global theme configuration
$crud->enableGlobalConfig();
echo $crud->renderForm(); // Applies theme from Global Config automatically
```

```
-- Configure multiple file upload in column metadata
ALTER TABLE properties
MODIFY COLUMN photos TEXT
COMMENT '{"type": "multiple_files", "accept": "image/*", "max_files": 10, "max_size": 5242880}';
```

**Features:**

- 📸 **Multiple File Upload** - Drag &amp; drop interface with previews
- 🎨 **Theme Integration** - Apply global theme to forms automatically
- 🏢 **White-label Ready** - Custom colors, fonts, logos per tenant
- 💾 **JSON Storage** - File paths stored as JSON array
- ✅ **Validation** - Max files, MIME types, file sizes

👉 [See Multiple Files Example](examples/15-multiple-files/)
👉 [See Theme Integration Example](examples/16-theme-integration/)

---

✨ What's New in v2.8
--------------------

[](#-whats-new-in-v28)

**Global Config Foundation** - Centralized configuration storage for application-wide settings!

```
# Set configuration
php bin/morpheus config:set application.name "My App"
php bin/morpheus config:set theme '{"primary_color":"#667eea"}'

# Get configuration
php bin/morpheus config:get application.name

# List all configuration
php bin/morpheus config:list

# Delete configuration
php bin/morpheus config:delete old.setting
```

```
// PHP usage
$config = new GlobalMetadata($pdo);
$config->set('app.name', 'My App');
$appName = $config->get('app.name');
```

👉 [See Global Config Examples](examples/14-global-config/)

---

✨ What's New in v2.7
--------------------

[](#-whats-new-in-v27)

**SQL Dump &amp; Import** - Export and import table structure and data with metadata preserved!

```
# Export SQL dump (structure + data + metadata)
php bin/morpheus dump:sql users --output=users.sql

# Structure only
php bin/morpheus dump:sql users --output=structure.sql --structure-only

# Data only
php bin/morpheus dump:sql users --output=data.sql --data-only

# Import SQL dump
php bin/morpheus import:sql backup.sql
php bin/morpheus import:sql backup.sql --force  # Skip confirmation
```

👉 [See SQL Dump Examples](examples/13-sql-dump/)

---

✨ What's New in v2.6
--------------------

[](#-whats-new-in-v26)

**Consolidation Release** - Improved documentation and developer experience!

- 📚 [Quick Start Guide](docs/QUICKSTART.md) - Get started in 5 minutes
- 🚀 [Migration Guide](docs/MIGRATION.md) - Upgrade between versions
- ✅ [Best Practices](docs/BEST_PRACTICES.md) - Production-ready patterns
- 📝 [Examples Guide](examples/README.md) - 30 examples with learning path

**Perfect for:**

- New users getting started
- Teams upgrading versions
- Production deployments
- Learning Morpheus

---

✨ What's New in v2.5
--------------------

[](#-whats-new-in-v25)

**Export/Import** - CSV export and import with validation and preview!

```
// Export to CSV
$csv = $crud->export('csv');
$crud->downloadExport('users.csv');

// Import from CSV with preview
$result = $crud->import($csvContent, ['preview' => true]);

// Generate import template
$template = $crud->generateImportTemplate();
```

```
# CLI commands
php bin/morpheus export:csv users --output=users.csv
php bin/morpheus import:csv users data.csv --preview
php bin/morpheus generate:template users --output=template.csv
```

👉 [See Export/Import Examples](examples/12-export-import/)

---

✨ What's New in v2.4
--------------------

[](#-whats-new-in-v24)

**CLI Enhancements** - Powerful new commands for webhook management and metadata operations!

```
# Test database connection
php bin/morpheus test:connection

# Configure webhooks easily
php bin/morpheus webhook:configure users https://webhook.site/abc123
php bin/morpheus test:webhook users

# Export/import metadata for backup and migration
php bin/morpheus metadata:export users --output=users.json
php bin/morpheus metadata:import users.json
```

👉 [See CLI Guide](docs/CLI.md)

---

✨ What's New in v2.3
--------------------

[](#-whats-new-in-v23)

**Notifications &amp; Webhooks** - Send email notifications and trigger webhooks automatically on CRUD events!

```
CREATE TABLE orders (
    id INT PRIMARY KEY,
    customer_name VARCHAR(255),
    amount DECIMAL(10,2)
) COMMENT = '{
    "notifications": {
        "on_create": {
            "email": ["admin@example.com"],
            "subject": "New Order #{{id}}",
            "template": "Customer: {{data.customer_name}}, Amount: ${{data.amount}}"
        }
    },
    "webhooks": [
        {
            "event": "on_create",
            "url": "https://api.example.com/webhook",
            "method": "POST",
            "headers": {"Authorization": "Bearer token"}
        }
    ]
}';
```

```
$crud = new Morpheus($pdo, 'orders');
$result = $crud->handleSubmission();
// Email sent + webhook triggered automatically!
```

👉 [See Notifications Guide](docs/NOTIFICATIONS.md)

---

✨ What's New in v2.2
--------------------

[](#-whats-new-in-v22)

**Validation Rules &amp; Business Logic** - Advanced validation configured entirely through table metadata!

```
CREATE TABLE products (
    id INT PRIMARY KEY,
    price DECIMAL(10,2),
    discount DECIMAL(5,2)
) COMMENT = '{
    "validation_rules": {
        "unique_together": [["sku", "category"]],
        "required_if": {
            "min_stock": {"status": "active"}
        },
        "conditional": {
            "discount": {
                "condition": "price > 100",
                "max": 50
            }
        }
    },
    "business_rules": {
        "max_records_per_user": 100,
        "require_approval": true
    }
}';
```

```
$crud = new Morpheus($pdo, 'products');
$result = $crud->handleSubmission();
// Validates: unique combinations, conditional requirements, business limits
```

👉 [See Validation Rules Guide](docs/VALIDATION_RULES.md)

---

✨ What's New in v2.1
--------------------

[](#-whats-new-in-v21)

**Authentication, RBAC &amp; Soft Deletes** - Complete user authentication, authorization, and soft delete support!

```
CREATE TABLE users (
    id INT PRIMARY KEY,
    email VARCHAR(255),
    password VARCHAR(255),
    role VARCHAR(50)
) COMMENT = '{
    "authentication": {
        "enabled": true,
        "registration": {"enabled": true, "auto_login": true},
        "login": {"max_attempts": 5, "lockout_duration": 900}
    },
    "permissions": {
        "create": ["guest"],
        "read": ["owner", "admin"],
        "update": ["owner", "admin"],
        "delete": ["admin"]
    }
}';
```

```
$crud = new Morpheus($pdo, 'users');
$crud->enableAuthentication();

// Login/Register
echo $crud->renderLoginForm();
echo $crud->renderRegistrationForm();
$result = $crud->handleAuthentication();

// Protected pages
if ($crud->isAuthenticated()) {
    $user = $crud->getCurrentUser();
    echo "Welcome, {$user['name']}!";
}

// Soft Deletes
$crud->delete($id);        // Soft delete (marks as deleted)
$crud->restore($id);       // Restore deleted record
$crud->forceDelete($id);   // Permanently delete
```

👉 [See RBAC &amp; Authentication Guide](docs/RBAC.md)

---

✨ What's New in v2.0
--------------------

[](#-whats-new-in-v20)

**Table Metadata System** - Configure everything via database table comments!

```
CREATE TABLE posts (
    id INT PRIMARY KEY,
    title VARCHAR(255),
    slug VARCHAR(255),
    created_at TIMESTAMP
) COMMENT = '{
    "display_name": "Blog Posts",
    "icon": "📝",
    "list_view": {"searchable": ["title"], "per_page": 20},
    "behaviors": {
        "timestamps": {"created_at": "created_at"},
        "sluggable": {"source": "title", "target": "slug"}
    }
}';
```

```
$crud = new Morpheus($pdo, 'posts');
echo $crud->renderList();  // Search, filters, pagination - all automatic!
$crud->handleSubmission(); // Slug and timestamps - automatic!
```

👉 [See Table Metadata Guide](docs/TABLE_METADATA.md)

---

🎯 Quick Start
-------------

[](#-quick-start)

### 1. Basic CRUD (3 lines of code!)

[](#1-basic-crud-3-lines-of-code)

```
