PHPackages                             simsaai/merlin - 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. [Framework](/categories/framework)
4. /
5. simsaai/merlin

ActiveLibrary[Framework](/categories/framework)

simsaai/merlin
==============

A lightweight, fast PHP framework for building modern MVC web applications and CLI tools. Merlin combines the best ideas from frameworks like Phalcon, CodeIgniter, and Laravel into a minimal yet powerful toolkit.

10PHP

Since Mar 6Pushed 2mo agoCompare

[ Source](https://github.com/SimsaAI/Merlin)[ Packagist](https://packagist.org/packages/simsaai/merlin)[ RSS](/packages/simsaai-merlin/feed)WikiDiscussions main Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Merlin MVC Framework
====================

[](#merlin-mvc-framework)

[![Merlin Logo](docs/images/merlin-logo-text-opt.svg)](docs/images/merlin-logo-text-opt.svg)

A lightweight, fast PHP framework for building modern MVC web applications and CLI tools. Merlin combines the best ideas from frameworks like Phalcon, CodeIgniter, and Laravel into a minimal yet powerful toolkit.

Why Merlin?
-----------

[](#why-merlin)

**Lightweight &amp; Fast** - Minimal dependencies and overhead. No bloat, just what you need.

**Modern PHP** - Built for PHP 8.0+, embracing type hints, named arguments, and modern patterns.

**Unified Query Builder** - One consistent, fluent API for all database operations, whether you're using models or raw queries.

**Flexible Architecture** - Use as much or as little as you need. Mix and match components freely.

**Secure by Default** - Prepared statements everywhere, CSRF protection, encryption helpers, and security best practices built in.

**Developer Friendly** - Intuitive APIs, clear error messages, and comprehensive documentation.

Features
--------

[](#features)

### MVC Stack

[](#mvc-stack)

- **Router** - Fast pattern matching with named routes, parameter validation, and middleware support
- **Controllers** - Clean action-based controllers with dependency injection
- **Dispatcher** - Flexible request dispatching with middleware pipeline
- **ViewEngine** - Fast PHP-based templating with layout support

### Database &amp; ORM

[](#database--orm)

- **Query Builder** - Unified fluent interface for SELECT, INSERT, UPDATE, DELETE
- **Active Record Models** - Expressive model API with relationships and validation
- **Prepared Statements** - SQL injection protection by default
- **Read/Write Splitting** - Built-in support for master/replica database setups
- **Connection Pooling** - Automatic reconnection and connection management
- **Schema Introspection** - Introspect database schema for dynamic models and migrations

### HTTP Utilities

[](#http-utilities)

- **Request** - Normalized access to GET, POST, headers, and file uploads
- **Response** - Fluent response building with JSON, redirects, and status codes
- **Session** - Simple session management with pluggable storage handlers
- **Cookies** - Easy cookie handling with encryption support
- **Middleware** - Composable request/response filters

### CLI Tools

[](#cli-tools)

- **Console** - Powerful CLI dispatcher with:
    - Auto-discovery of tasks from namespaces
    - Flexible task grouping and custom namespaces
    - Rich color output and styled help pages
    - Option parsing and argument separation
    - Built-in help and task listing
- **Tasks** - Structured CLI commands with parameter parsing
- **Sync Task** - built-in sync task for generating/applying model and schema changes

### Additional Features

[](#additional-features)

- **Security** - CSRF tokens, password hashing, encryption (Sodium/OpenSSL)
- **Logging** - Event-based logging hooks for database and application events
- **Pagination** - Built-in query pagination support
- **Exception Handling** - Structured exception hierarchy
- **AppContext** - Centralized service container for shared resources

Requirements
------------

[](#requirements)

- PHP &gt;= 8.0
- PDO extension (`ext-pdo`)
- Multibyte String extension (`ext-mbstring`)
- Optional: Sodium or OpenSSL extension for advanced encryption features

(PDO driver support is implemented for MySQL, PostgreSQL and SQLite. Other drivers may work but are not officially tested.)

Installation
------------

[](#installation)

Install via Composer:

```
composer require simsaai/merlin
```

Quick Start
-----------

[](#quick-start)

### Web Application (MVC)

[](#web-application-mvc)

Create a simple web application with routing and controllers:

```
