Skip to content

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.

License

Notifications You must be signed in to change notification settings

trymorpheus/morpheus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Morpheus

Tests Code Quality Packagist Version PHP Version License Downloads

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 | ๐Ÿ“– Universal CMS Vision | ๐Ÿ—บ๏ธ Complete Roadmap


โœจ Features

๐Ÿš€ 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

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

โšก 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

composer require trymorpheus/morpheus

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

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)

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 & 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
๐Ÿ‘‰ See Theme Showcase Example
๐Ÿ‘‰ See One-Click Installer Example
๐Ÿ‘‰ See Media Library Example
๐Ÿ‘‰ See Comment System Example


โœจ What's New in v3.5

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
๐Ÿ‘‰ See Release Notes


โœจ What's New in v3.4

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


โœจ What's New in v3.3

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', '<p>Content</p>');
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


โœจ What's New in v3.2

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


โœจ What's New in v3.1

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


โœจ What's New in v3.0

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


โœจ What's New in v2.9

Multiple File Upload & Theme Integration - Upload multiple files with drag & 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 & 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
๐Ÿ‘‰ See Theme Integration Example


โœจ What's New in v2.8

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


โœจ What's New in v2.7

SQL Dump & 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


โœจ What's New in v2.6

Consolidation Release - Improved documentation and developer experience!

Perfect for:

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

โœจ What's New in v2.5

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


โœจ What's New in v2.4

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


โœจ What's New in v2.3

Notifications & 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


โœจ What's New in v2.2

Validation Rules & 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


โœจ What's New in v2.1

Authentication, RBAC & 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 & Authentication Guide


โœจ What's New in v2.0

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


๐ŸŽฏ Quick Start

1. Basic CRUD (3 lines of code!)

<?php
require 'vendor/autoload.php';

use Morpheus\Morpheus;

// MySQL
$pdo = new PDO('mysql:host=localhost;dbname=mydb', 'user', 'pass');
// PostgreSQL
// $pdo = new PDO('pgsql:host=localhost;dbname=mydb', 'user', 'pass');

$crud = new Morpheus($pdo, 'users');

// That's it! Handle both display and submission
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $result = $crud->handleSubmission();
    echo $result['success'] ? "Saved! ID: {$result['id']}" : "Error";
} else {
    echo $crud->renderForm($_GET['id'] ?? null); // null = create, ID = edit
}

2. Customize with JSON Metadata

Add metadata to your table columns using JSON in comments:

ALTER TABLE users 
MODIFY COLUMN email VARCHAR(255) 
COMMENT '{"type": "email", "label": "Email Address", "tooltip": "We will never share your email"}';

ALTER TABLE users 
MODIFY COLUMN age INT 
COMMENT '{"type": "number", "min": 18, "max": 120}';

ALTER TABLE users 
MODIFY COLUMN created_at TIMESTAMP 
COMMENT '{"hidden": true}';

3. Foreign Keys (Automatic!)

// If 'posts' table has a foreign key to 'users', 
// Morpheus automatically creates a dropdown with user names
$crud = new Morpheus($pdo, 'posts');
echo $crud->renderForm();
// Dropdown shows: "John Doe", "Jane Smith", etc.

4. Many-to-Many Relationships

$crud = new Morpheus($pdo, 'posts');

// Configure M:N relationship (posts โ†” tags via post_tags pivot table)
$crud->addManyToMany(
    'tags',              // Field name in form
    'post_tags',         // Pivot table
    'post_id',           // Local key
    'tag_id',            // Foreign key
    'tags'               // Related table
);

echo $crud->renderForm($_GET['id'] ?? null);
// Renders a multi-select with all available tags

5. Hooks for Custom Logic

$crud = new Morpheus($pdo, 'posts');

// Auto-generate slug before saving
$crud->addHook('beforeSave', function($data) {
    $data['slug'] = strtolower(str_replace(' ', '-', $data['title']));
    return $data;
});

// Log after creation
$crud->addHook('afterCreate', function($data, $id) {
    error_log("New post created: ID $id");
});

$crud->handleSubmission();

6. Virtual Fields

use Morpheus\VirtualField;

$crud = new Morpheus($pdo, 'users');

// Add password confirmation field (not stored in database)
$crud->addVirtualField(new VirtualField(
    name: 'password_confirmation',
    type: 'password',
    label: 'Confirm Password',
    required: true,
    validator: fn($value, $data) => $value === ($data['password'] ?? ''),
    attributes: [
        'placeholder' => 'Repeat your password',
        'error_message' => 'Passwords do not match'
    ]
));

// Hash password before saving
$crud->beforeSave(function($data) {
    $data['password'] = password_hash($data['password'], PASSWORD_DEFAULT);
    return $data;
});

7. Internationalization (i18n)

// Auto-detects language from URL (?lang=es), session, or browser
$crud = new Morpheus($pdo, 'users');

// Or force a specific language
$crud = new Morpheus($pdo, 'users', locale: 'es');

echo $crud->renderForm();
// Form, validation messages, and UI are now in Spanish!

Language Switcher:

<a href="?lang=en">๐Ÿ‡ฌ๐Ÿ‡ง English</a>
<a href="?lang=es">๐Ÿ‡ช๐Ÿ‡ธ Espaรฑol</a>
<a href="?lang=fr">๐Ÿ‡ซ๐Ÿ‡ท Franรงais</a>

8. Template System

use Morpheus\Template\BladeTemplate;

// Create template engine
$engine = new BladeTemplate(__DIR__ . '/templates', __DIR__ . '/cache');

// Use with Morpheus
$crud = new Morpheus($pdo, 'users');
$crud->setTemplateEngine($engine);

// Or render templates directly
echo $engine->render('Hello, {{ $name }}!', ['name' => 'World']);

Blade-like syntax:

@if ($user->isAdmin())
    <p>Welcome, Admin!</p>
@else
    <p>Welcome, User!</p>
@endif

@foreach ($items as $item)
    <li>{{ $item }}</li>
@endforeach

9. Audit Logging

$crud = new Morpheus($pdo, 'users');
$crud->enableAudit($userId); // Track who changed what

$crud->handleSubmission();
// Automatically logs: action, user_id, IP, old_values, new_values

๐Ÿ“š Documentation

v3.3 Features (NEW!)

  • UI Components Guide - 15 reusable components
  • Components Library - Alerts, badges, buttons, cards, modals, tabs, tables, and more

v3.2 Features

  • Workflow Engine Guide - State management with transitions
  • Workflow System - Permission-based transitions and history tracking

v3.1 Features

  • Admin Panel Generator - Complete admin panel with dashboard
  • Sidebar Navigation - Customizable menu with icons

v3.0 Features

  • REST API Generator - Automatic REST API with JWT auth
  • OpenAPI/Swagger - Auto-generated API documentation

v4.0 Features (NEW!)

v2.9 Features

  • Multiple File Upload - Drag & drop with previews
  • Theme Integration - White-label theming from Global Config

v2.8 Features

v2.7 Features

  • SQL Dump & Import - Export/import with metadata preservation

v2.6 Features

v2.5 Features

  • Export/Import - CSV export and import with validation

v2.4 Features

v2.3 Features

v2.2 Features

v2.1 Features

v2.0 Features

Core Features

Getting Started

Setup & Contributing


๐ŸŽจ Metadata Options

Configure fields via JSON in COLUMN_COMMENT:

Option Type Description Example
type string Input type "email", "url", "color", "tel", "password", "search", "time", "week", "month", "range", "file"
label string Field label "Your Email"
placeholder string Placeholder text "Enter your name"
min int Min value (number) 18
max int Max value (number) 120
minlength int Min length (text) 3
pattern string Regex pattern "[0-9]{3}-[0-9]{3}-[0-9]{4}"
step string Step increment "0.01", "any"
tooltip string Help text "Enter a valid URL"
readonly bool Read-only field true
hidden bool Hide from form true
autocomplete string Autocomplete hint "email", "tel", "off"
display_column string FK display field "full_name"
accept string File types "image/*"
max_size int Max file size (bytes) 2097152 (2MB)
max_files int Max files (multiple_files) 10

Example:

COMMENT '{"type": "email", "label": "Email", "tooltip": "Required field", "minlength": 5}'

๐Ÿ”’ Security Features

โœ… CSRF Protection - Automatic token generation and validation
โœ… SQL Injection Prevention - Prepared statements only
โœ… XSS Protection - Automatic input sanitization
โœ… File Upload Security - Real MIME type validation with finfo
โœ… Transaction Safety - Automatic rollback on errors


๐Ÿ› ๏ธ Available Hooks

Hook Timing Use Case
beforeValidate Before validation Modify data before checks
afterValidate After validation Additional validation
beforeSave Before INSERT/UPDATE Generate slugs, timestamps
afterSave After INSERT/UPDATE Logging, notifications
beforeCreate Before INSERT only Set default values
afterCreate After INSERT only Send welcome email
beforeUpdate Before UPDATE only Track changes
afterUpdate After UPDATE only Clear cache
beforeDelete Before DELETE Check dependencies
afterDelete After DELETE Cleanup files

๐Ÿงช Testing

Morpheus has comprehensive test coverage:

  • 300 tests with 582+ assertions
  • 100% passing rate (300 passing, 0 failing)
  • 90% code coverage
  • Automated CI/CD with GitHub Actions
  • Tests run on PHP 8.0, 8.1, 8.2, 8.3
# Run all tests
php vendor/phpunit/phpunit/phpunit

# Run specific test suite
php vendor/phpunit/phpunit/phpunit tests/AuthenticationManagerTest.php
php vendor/phpunit/phpunit/phpunit tests/PermissionManagerTest.php
php vendor/phpunit/phpunit/phpunit tests/SoftDeletesTest.php

๐Ÿšฆ Roadmap

๐Ÿ‘‰ See Complete Roadmap - Detailed plan for v3.6-v6.0
๐Ÿ‘‰ Universal CMS Strategy - WordPress alternative vision
๐Ÿ‘‰ v4.0 Implementation Plan - Technical details for v4.0

๐ŸŒŸ Coming in v4.0 - Universal CMS Foundation (Q3 2025)

The Game-Changing Release - Transform Morpheus into a WordPress alternative!

Core Features:

  • โœจ One-Click Installer - Working site in 60 seconds
  • ๐Ÿ“ฆ 4 Content Types - Blog, Portfolio, E-commerce, Directory
  • ๐ŸŽจ 5 Professional Themes - Ready-to-use designs
  • ๐ŸŒ Frontend Rendering - Public-facing pages with SEO
  • ๐Ÿ”„ WordPress Migrator - Import your WP site in minutes
  • ๐Ÿš€ 10x Faster - <500ms load time vs 2-3s for WordPress

Why v4.0 Matters:

  • ๐ŸŽฏ Market: 810M WordPress sites (potential users)
  • ๐Ÿ’ฐ Revenue: $2.1M ARR target in Year 1
  • ๐Ÿ† Position: First CMS that grows into any app
  • ๐Ÿ”ฅ Viral: "Migrated from WordPress in 10 minutes"

Timeline: 12-16 weeks | Launch: September 2025

โœ… Completed (v2.1.0)

  • Authentication System
    • User registration with auto-login
    • Secure login with rate limiting
    • Session management with remember me
    • Password hashing (bcrypt)
  • RBAC (Role-Based Access Control)
    • Table-level permissions
    • Row-level security
    • Automatic enforcement in forms/lists
  • Soft Deletes
    • Mark records as deleted without removing
    • Restore deleted records
    • Force delete for permanent removal
  • AuthenticationManager class
  • PermissionManager class
  • 5 new examples (4 auth + 1 soft deletes)
  • 52 new tests (100% passing)

โœ… Completed (v2.0.0)

  • Table Metadata System (Phase 1 - Quick Wins)
    • UI/UX Customization (list views, colors, icons)
    • Dynamic Forms (tabs, fieldsets)
    • Automatic Behaviors (timestamps, sluggable)
    • Search & Filters (full-text search + filters)
  • ListGenerator class with search/filter rendering
  • TableMetadata class with 20+ methods
  • 4 new examples in 06-table-metadata/
  • Complete documentation (TABLE_METADATA.md)

โœ… Completed (v1.0.0)

  • Full CRUD operations (Create, Read, Update, Delete)
  • Foreign key relationships
  • Many-to-many relationships
  • Hooks/Events system
  • Audit logging
  • File uploads
  • Client + Server validation
  • Caching system
  • Comprehensive test suite

โœ… Completed (v1.3.0)

  • PostgreSQL support with Adapter pattern
  • Auto-detection of database driver
  • Docker setup for MySQL & PostgreSQL

โœ… Completed (v1.2.0)

  • Virtual fields (password confirmation, terms acceptance)
  • Comprehensive test suite (113 tests)
  • CI/CD pipeline (GitHub Actions)
  • FormGenerator enhancements (16+ metadata options)

โœ… Completed (v1.4.0)

  • Internationalization (i18n) - 3 languages (EN, ES, FR)
  • Advanced M:N UI (checkboxes with search)
  • Translator class with auto-detection
  • Client + Server translation support
  • 31 new tests for i18n (100% passing)

โœ… Completed (v1.5.0)

  • Template System - Blade-like syntax
  • Layout inheritance (@extends, @section, @yield)
  • Partials (@include)
  • Automatic escaping ({{ }} vs {!! !!})
  • File caching for performance
  • 17 new tests for templates (100% passing)

โœ… Completed (v2.2.0)

  • Validation Rules
    • unique_together - Composite unique constraints
    • required_if - Conditional required fields
    • conditional - Dynamic min/max validation
  • Business Rules
    • max_records_per_user - Record limits per user
    • require_approval - Approval workflows
  • ValidationRulesEngine class
  • 4 new examples in 10-validation-rules/
  • 12 new tests (100% passing)

โœ… Completed (v2.3.0)

  • Notifications & Webhooks
    • Email notifications with template placeholders
    • Webhook triggers with custom headers
    • Field-specific update notifications
    • Multiple recipients and webhooks
    • Non-blocking error handling
  • NotificationManager class
  • 2 new examples in 11-notifications/
  • 7 new tests (100% passing)

โœ… Completed (v2.9.0)

  • Multiple File Upload
    • Drag & drop interface with file previews
    • Multiple file handling with JSON storage
    • Max files validation
    • Existing file management
  • Theme Integration
    • Global theme configuration support
    • CSS variables injection
    • White-label branding (logo, app name)
    • Per-tenant theming capability
  • ThemeManager class
  • FileUploadHandler enhancements
  • 2 new examples (real estate, theme demo)
  • 9 new tests (100% passing)

โœ… Completed (v3.0.0)

  • REST API Generator
    • Automatic CRUD endpoints for all tables
    • JWT authentication with token generation
    • OpenAPI/Swagger documentation
    • CORS support for cross-origin requests
    • Pagination for list endpoints
    • RBAC integration optional
  • RestAPIGenerator class
  • 1 new example (REST API tester)
  • 7 new tests (100% passing)

โœ… Completed (v3.1.0)

  • Admin Panel Generator
    • Complete admin panel with sidebar navigation
    • Dashboard with automatic stats
    • Breadcrumbs for contextual navigation
    • User menu with avatar
    • Responsive mobile-first design
    • Full integration with Morpheus components
  • AdminPanel class
  • 1 new example (complete admin panel)
  • 12 new tests (100% passing)

โœ… Completed (v3.2.0)

  • Workflow Engine
    • State management with configurable states
    • Transitions with from/to state validation
    • Permission-based transition control
    • Automatic transition buttons in forms
    • Complete history tracking with audit trail
    • Lifecycle hooks (before/after transitions)
    • State labels with custom colors
    • Multiple from states support
  • WorkflowEngine class
  • 1 new example (order management workflow)
  • 13 new tests (100% passing)

โœ… Completed (v3.3.0)

  • UI Components Library
    • 15 reusable components (alert, badge, button, card, modal, tabs, accordion, table, etc.)
    • Themeable with custom colors
    • Accessible with ARIA labels
    • Responsive mobile-first design
    • Zero dependencies
    • XSS protection built-in
  • Components class with static methods
  • 1 new example (UI components showcase)
  • 26 new tests (100% passing)

๐Ÿ”ฎ Planned (v4.0+) - Universal CMS Era

v4.0 - Universal CMS Foundation (Q3 2025)

  • Content type system (blog implemented)
  • Frontend rendering engine with SEO
  • One-click installer (WordPress-style) โœ…
  • 3 professional themes (Minimal, Modern, Classic)
  • WordPress migration tool โœ…
  • Media library โœ…
  • Comment system โœ…

v4.1 - CMS Advanced Features (Q4 2025)

  • Theme marketplace
  • Page builder (drag & drop)
  • Widget system
  • Menu builder
  • Revision history
  • Scheduled publishing

v4.2 - CMS SEO & Performance (Q1 2026)

  • Built-in SEO optimization
  • Image optimization (WebP)
  • CDN integration
  • Multi-layer caching
  • PWA capabilities

v4.3 - Multi-Tenant & SaaS (Q2 2026)

  • Tenant isolation
  • White-label capabilities
  • Usage tracking & billing
  • Subdomain routing

๐Ÿ“Š Project Stats

  • 58 PHP classes (~19,500 lines)
  • 43 working examples (1 in v4.0, 1 in v3.3, 1 in v3.2, 1 in v3.1, 1 in v3.0, 2 in v2.9, 1 in v2.8, 1 in v2.7, 2 in v2.5, 2 in v2.3, 4 in v2.2, 6 in v2.1, 4 in v2.0)
  • 23 technical documents
  • 421 automated tests (418 passing, 99.3% pass rate, 90% coverage) (1 in v3.3, 1 in v3.2, 1 in v3.1, 1 in v3.0, 2 in v2.9, 1 in v2.8, 1 in v2.7, 2 in v2.5, 2 in v2.3, 4 in v2.2, 6 in v2.1, 4 in v2.0)
  • 22 technical documents
  • 366 automated tests (100% passing, 90% coverage)
  • 19 CLI commands
  • Languages supported: 3 (English, Spanish, French)
  • Databases supported: 2 (MySQL, PostgreSQL)
  • Template engine: Blade-like syntax
  • CLI Tool: 20 commands (init, install, generate, validate, clear, list, export, import, etc.)
  • Authentication: Register, login, logout, password reset, rate limiting
  • RBAC: Table + row-level permissions
  • Soft Deletes: Delete, restore, force delete
  • Validation Rules: 3 types (unique_together, required_if, conditional)
  • Business Rules: 2 types (max_records_per_user, require_approval)
  • Table metadata features: 6 (UI/UX, Forms, Behaviors, Search, Validation, Business)
  • File Upload: Single + multiple with drag & drop
  • Theming: Global config with CSS variables
  • REST API: Automatic generation with JWT auth
  • Admin Panel: Complete admin interface with dashboard
  • Refactored Classes: 6 (FormGenerator, ListGenerator, AdminPanel, CRUDHandler, ValidationEngine, SchemaAnalyzer)

๐Ÿค Contributing

Contributions are welcome! Please read CONTRIBUTING.md for guidelines.

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

๐Ÿ‘ฅ Credits

Creator & Project Lead: Mario Raรบl Carbonell Martรญnez
Development: Amazon Q (Claude Sonnet 4.5)


๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐ŸŒŸ Show Your Support

If you find this project useful, please consider:

  • โญ Starring the repository
  • ๐Ÿ› Reporting bugs
  • ๐Ÿ’ก Suggesting new features
  • ๐Ÿ“ข Sharing with others

Made with โค๏ธ by Mario Raรบl Carbonell Martรญnez

About

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.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •