PHPackages                             donchev/framework - 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. donchev/framework

ActivePackage[Framework](/categories/framework)

donchev/framework
=================

A Tiny PHP Framework

2.0.1(1y ago)325MITPHPPHP &gt;=8.2

Since Oct 21Pushed 1y ago1 watchersCompare

[ Source](https://github.com/vdonchev/framework)[ Packagist](https://packagist.org/packages/donchev/framework)[ RSS](/packages/donchev-framework/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (15)Versions (12)Used By (0)

Tiny Framework
==============

[](#tiny-framework)

A lightweight and expressive PHP framework built for clarity, structure, and extensibility. Ideal for small to mid-sized web applications.

---

Features
--------

[](#features)

### Built-in functionalities

[](#built-in-functionalities)

- Dependency Injection Container (PHP-DI)
- Routing (FastRoute)
- Middleware support
- Templating with Twig
- Flash messages
- Database support via MeekroDB
- SMTP mailer (Nette Mail)
- Console commands (Symfony Console)
- Caching (Symfony Cache)
- Logging (donchev/simple-logger)
- Data validation and sanitization

Includes **Bootstrap 5** and **Bootstrap Icons** for UI development.

---

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

[](#requirements)

- PHP 8.2 or higher

---

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

[](#installation)

You can install the framework using Composer.

```
composer create-project donchev/framework myapp
```

---

Configuration
-------------

[](#configuration)

All application configuration is located in `config/settings.yaml`. Example:

```
app:
  env: dev
  name: Tiny Framework
  base_url: https://framework.test
  use_sessions: true
  log_file: '%var_dir%/log/framework.log'

api:
  username:
  password:

middleware:
  dir: '%base_dir%/src/Middleware'
  namespace: Donchev\Framework\Middleware

db:
  host:
  name:
  username:
  password:
  port: 3306
  charset: utf8mb4

mail:
  host: smtp.mailtrap.io
  username:
  password:
  secure: null
  port: 2525
  from_name: 'Tiny Framework Mailer'
  from_email:
```

Override values via `settings.local.yaml`.

---

Usage
-----

[](#usage)

### Routing

[](#routing)

Define routes in `config/routes.php`:

```
return static function (RouteCollector $router) {
    $router->get('/', [HomeController::class, 'index']);
    $router->post('/submit', [ContactController::class, 'submit']);
    $router->get('/blog/{slug}', [BlogController::class, 'show']);
};
```

---

### Controllers

[](#controllers)

Controllers extend `AbstractController`:

```
class HomeController extends AbstractController
{
    public function index(): void
    {
        $this->renderTemplate('home/index.html.twig', [
            'title' => 'Welcome!'
        ]);
    }
}
```

---

### Sending Emails

[](#sending-emails)

```
use Nette\Mail\Message;

$message = new Message();
$message->setFrom('you@site.com')
        ->addTo('user@example.com')
        ->setSubject('Hello')
        ->setBody('This is a test email.');

$mailer = $container->get(Mailer::class);
$mailer->send($message);
```

---

### Database (MeekroDB)

[](#database-meekrodb)

```
/** @var MeekroDB $db */
$db = $container->get(MeekroDB::class);

$users = $db->query("SELECT * FROM users WHERE active = %i", 1);
```

---

### Using Cache

[](#using-cache)

```
use Symfony\Contracts\Cache\CacheInterface;

$cache = $container->get(CacheInterface::class);

$data = $cache->get('some_key', function () {
    return 'cached value';
});
```

---

### Flash Messages

[](#flash-messages)

Set flash messages in controller:

```
$flash = new FlashService();
$flash->add('success', 'Saved successfully!');
```

Render them in Twig:

```
{% include '_flash.html.twig' with {'flashes': flashes} %}
```

---

### Middleware

[](#middleware)

Implement `MiddlewareInterface` and drop your class into `src/Middleware`. It will be auto-loaded.

```
class RequestLoggerMiddleware implements MiddlewareInterface
{
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        // logging logic...
        return $handler->handle($request);
    }
}
```

---

### Twig Template Globals

[](#twig-template-globals)

Twig templates automatically have access to:

- `http_get`, `http_post`, `http_cookie`, `http_session`
- `settings`
- `get_flash()` function

---

### Data Validator &amp; Sanitizer

[](#data-validator--sanitizer)

**Validator:**

```
$validator = new DataValidator();

$data = [
    'name' => 'John Doe',
    'age' => 32
];

$rules = [
    'name' => 'string',
    'age' => 'min:30'
];

$result = $validator->validate($data, $rules);

// Output:
[
  'age' => [
    '"age" must have at least 30 characters'
  ]
]
```

**Validator &amp; Flash Messages:**

```
class AuthController
{
    public function login(Post $post, DataValidator $validator, FlashService $flashService): void
    {
        $data = [
            'email' => $post->get('email'),
            'password' => $post->get('password'),
        ];

        $rules = [
            'email' => 'required|email',
            'password' => 'required|secure',
        ];

        $errors = $validator->validate($data, $rules);

        if (!empty($errors)) {
            $flashService->addError($errors);
            // return or redirect with errors
        }

        //...
    }
}
```

**Sanitizer:**

```
$sanitizer = new DataSanitizer();

$data = ['asd123', '1.5ds'];
$sanitized = $sanitizer->sanitize($data, 'float');

// Output: [123.0, 1.5]
```

---

### Console Commands

[](#console-commands)

Define commands in `bin/console`. Example:

```
class HelloCommand extends Command
{
    protected string $signature = 'hello';
    protected string $description = 'Says hello';

    public function handle(): void
    {
        $this->info('Hello from the Tiny Framework!');
    }
}
```

Run them:

```
php bin/console hello
```

---

Code Style
----------

[](#code-style)

This project uses **php-cs-fixer**. You can format your code using:

```
composer cs-fix
```

Check for issues without modifying files:

```
composer cs-check
```

---

Testing
-------

[](#testing)

The framework includes PHPUnit 12+ test coverage out of the box.

Run tests:

```
vendor/bin/phpunit
```

All test files are located in the `tests/` folder and follow PSR-4 autoloading with the `Tests\` namespace.

---

Development Mode
----------------

[](#development-mode)

Set `app.env: dev` to enable detailed error pages (via Whoops) and debugging tools.

---

Production
----------

[](#production)

Set `app.env: prod` to enable compiled container and cache.

---

License
-------

[](#license)

This project is open-source and licensed under the [MIT License](LICENSE).

---

Author
------

[](#author)

Developed by Donchev. Contributions are welcome.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance46

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~127 days

Recently: every ~192 days

Total

11

Last Release

400d ago

Major Versions

1.1.4 → 2.0.02025-04-12

### Community

Maintainers

![](https://www.gravatar.com/avatar/3513f314d354f4af05dd4e0b49a8969242ad19b5c87a4a81415e9c0a2bafdbf4?d=identicon)[donchev](/maintainers/donchev)

---

Top Contributors

[![vdonchev](https://avatars.githubusercontent.com/u/12625450?v=4)](https://github.com/vdonchev "vdonchev (51 commits)")

---

Tags

dependency-injectionframeworkmysqlphp

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/donchev-framework/health.svg)

```
[![Health](https://phpackages.com/badges/donchev-framework/health.svg)](https://phpackages.com/packages/donchev-framework)
```

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[silverstripe/framework

The SilverStripe framework

7213.5M2.5k](/packages/silverstripe-framework)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
