PHPackages                             zeretei/php-core - 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. zeretei/php-core

ActiveLibrary[Framework](/categories/framework)

zeretei/php-core
================

A lightweight, zero-dependency PHP MVC micro-framework.

0.2.0(1mo ago)13MITPHPPHP &gt;=8.2

Since Jul 8Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/zerexei/php-core)[ Packagist](https://packagist.org/packages/zeretei/php-core)[ RSS](/packages/zeretei-php-core/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (1)Versions (8)Used By (0)

PHP Core
========

[](#php-core)

 A lightweight, zero-dependency PHP MVC micro-framework.

 [![Latest Version on Packagist](https://camo.githubusercontent.com/25ca3c2480785272a4a570679547ad1e908939e6df9dc1e62eadf2f1a8b25c1d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a6572657465692f7068702d636f72652e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/25ca3c2480785272a4a570679547ad1e908939e6df9dc1e62eadf2f1a8b25c1d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a6572657465692f7068702d636f72652e7376673f7374796c653d666c61742d737175617265) [![Total Downloads](https://camo.githubusercontent.com/e951a6c03e9c0532af59ab48b2b07b73f565972d9cd60a51802658d7d225af4f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a6572657465692f7068702d636f72652e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/e951a6c03e9c0532af59ab48b2b07b73f565972d9cd60a51802658d7d225af4f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a6572657465692f7068702d636f72652e7376673f7374796c653d666c61742d737175617265) [![MIT License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265) [![PHP 8.2+](https://camo.githubusercontent.com/e165e38e31a9c99f58cf8c034b981119d63b6ecea34f71784c0740feb10fe457/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230382e322d3737376262342e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/e165e38e31a9c99f58cf8c034b981119d63b6ecea34f71784c0740feb10fe457/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230382e322d3737376262342e7376673f7374796c653d666c61742d737175617265) [![PSR-4 Compliant](https://camo.githubusercontent.com/c82d054d22362479f1e362e5678985919020c31533e941fdd21749e7b743f64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5053522d2d342d636f6d706c69616e742d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/c82d054d22362479f1e362e5678985919020c31533e941fdd21749e7b743f64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5053522d2d342d636f6d706c69616e742d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)

---

A minimal PHP 8.2+ MVC micro-framework with a service container, router, PDO query builder, model abstractions, middleware pipeline, and session flash bags. Zero runtime dependencies.

Features
--------

[](#features)

- ⚡ **Lightweight IoC Container** — Simple service binding and resolution via a static registry.
- 🛣️ **Flexible Routing** — GET, POST, PUT, PATCH, DELETE with typed wildcard parameters (`:int`, `:str`, `:char`, `:any`).
- 🛡️ **Auto-Sanitized Input** — Recursive HTML-entity encoding on all request input at construction time.
- 💾 **Query Builder &amp; Migrations** — Parameterized PDO statements and a file-based migration runner with an applied-migrations table.
- 🔑 **Model Blueprints** — Base `Model` with a `$fillable` mass-assignment guard and built-in CRUD.
- 🎛️ **Controller &amp; Middleware Pipeline** — Base `Controller` with per-action middleware scoping via `shouldExecute()`.
- ✉️ **Flash &amp; Error Bags** — Two-pass session flash bags: one for notifications, one for validation errors.
- 🐧 **PSR-4 Autoloading** — Standardized, case-sensitive-filesystem-safe folder names.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Project Structure](#project-structure)
- [Bootstrap](#bootstrap)
- [Configuration](#configuration)
- [Container](#container)
- [Routing](#routing)
- [Request &amp; Validation](#request--validation)
- [Response](#response)
- [Database](#database)
- [Models](#models)
- [Controllers](#controllers)
- [Middleware](#middleware)
- [Session](#session)
- [Migrations](#migrations)
- [License](#license)

---

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

[](#installation)

Require via Composer:

```
composer require zeretei/php-core
```

Then add your application namespace to your project's `composer.json`:

```
{
    "autoload": {
        "psr-4": {
            "App\\": "app/"
        }
    }
}
```

```
composer dump-autoload
```

---

Project Structure
-----------------

[](#project-structure)

A typical project using PHP Core looks like this:

```
project/
├── app/
│   ├── Controllers/
│   ├── Middleware/
│   ├── Models/
│   ├── Databases/
│   │   └── migrations/
│   ├── Views/
│   └── routes.php
├── public/
│   └── index.php          # Entry point
├── config.php
└── composer.json

```

---

Bootstrap
---------

[](#bootstrap)

Create `public/index.php` as the single entry point:

```
