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 2w ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Merlin - PHP Web Framework
==========================

[](#merlin---php-web-framework)

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

### Lightweight by Design. Powerful in Practice.

[](#lightweight-by-design-powerful-in-practice)

A lightweight, fast PHP framework for building modern Web applications and CLI tools. Merlin combines the best ideas from frameworks like Phalcon, CodeIgniter, Laravel and Symfony 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.1+, 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** - Clarity template engine with auto-escaping, template inheritance, and a filter pipeline (A native PHP engine is also available for maximum performance)

### Database &amp; ORM

[](#database--orm)

- **Query Builder** - Unified fluent interface for SELECT, INSERT, UPDATE, DELETE
- **Active Record Models** - Expressive model API with state tracking and typed property support
- **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
- **ModelSync Task (`model-sync`)** - Built-in CLI task for synchronizing PHP models with the database schema, generating migration/migration-like changes and optionally applying them.

### Additional Features

[](#additional-features)

- **Validation** - Fluent field rules with type coercion, nested list/object validation, and error collection
- **Security** - CSRF tokens, password hashing, encryption (Sodium/OpenSSL)
- **Logging** - Event-based logging hooks for database and application events
- **Pagination** - Built-in query pagination with automatic total-count queries
- **Exception Handling** - Structured exception hierarchy
- **AppContext** - Centralized service container for shared resources

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

[](#requirements)

- PHP &gt;= 8.1
- 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 sailantis/merlin-mvc
```

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

[](#quick-start)

### Web Application (MVC)

[](#web-application-mvc)

Create a simple web application with routing and controllers:

```
