Skip to content

designbymalina/dbmframework

Repository files navigation

DbM Framework - Ultra Fast PHP Framework for High-Performance Web Apps

Fast. Flexible. PSR-Compatible. Modern PHP MVC/MVP Framework + CMS Engine with built-in API

PHP Version PSR Build Coverage Composer Speed License

DBM Framework PHP MVC MVP + DBM CMS, Version 5
All copyrights reserved by Design by Malina (DbM)
Website: www.dbm.org.pl

About the Framework

DBM Framework v5 is a modular monolith PHP designed for building long-lasting, maintainable applications with full control over architecture and performance. The framework combines the lightweight simplicity of classic MVC/MVP with a modern approach to application expansion through clearly separated modules, without imposing redundant abstractions or hidden logic.

Earlier versions of the DBM Framework were based on a classic monolithic architecture. Version 5 introduces modularity, enabling the logical separation of responsibilities within a single system implemented as a whole. This approach preserves the simplicity and efficiency of the monolith while ensuring scalability, readability, and long-term architectural stability.

The framework also forms the foundation of the DBM platform, including the DBM CMS turnkey solution enabling rapid website and application launches without the need to build your own infrastructure from scratch. The CMS can operate as a lightweight file- and template-based system or be extended with administrative and database modules, maintaining full control over the application's code and structure.

The DBM Framework is designed for teams and projects that require predictable operation, high performance, and an architecture that is resilient to growth and long-term development.

DbM Framework is:

Ultra-fast core - Optimized request Routing and Caching
PSR (1, 4, 11, 12) Compliant - Industry Standard Ready Code
REST API Routing - Lightweight, Ready, Lightweight
Smart DI Container - Manual or Semi-Automatic Dependency Injection
Composer & Autoload - Ready to Use in Any Project
Ultra Fast View Engine 2.0 - Speed ​​Similar to Native PHP
DbM CMS - Framework-Based Content Management System, Ready-Made Authentication and Administration Panel

DbM is a framework that doesn't fight the developer - it lets them work the way they want.

Framework Structure

  • application/ - framework core: classes, interfaces, libraries (+ Routing, DI, API)
  • bin - executables: console command interface and worker (entrypoint: bin/dbm)
  • config/ - configuration files (optional, e.g., php.ini, CMS modules)
  • frontend/ - frontend (optional React.js or Vue.js, Node.js, Webpack)
  • libraries/ - external libraries (PSR, PHPMailer, Guzzle)
  • public/ - public files (domain root)
  • src/ - application logic: controllers, services, models, services
  • templates/ - view templates
  • tests/ - unit tests
  • translations/ - translation files (optional)
  • var/ - cache and logs (automatically created, write permissions required)
  • vendor/ - libraries installed by Composer (automatically created)
  • .env.example - sample environment configuration

Additional Structure for CMS installations

  • _Documents - documentation, module installation archive
  • data/ - data and files (write permissions required)
  • modules/ - content management system modules

Installation and Configuration (manual installation)

  1. Domain Configuration: Point your domain to the public/ directory. If you are using a local environment (localhost), copy the .htaccess file from _Documents/_Server/ to the project root. Then, in both files – the root directory and public/.htaccess – adjust the RewriteBase directive to match your application's execution path.
  2. Environment File: Configure the .env.example file, then rename it to .env.
  3. Optimization: After completing the configuration and launching the system, set CACHE_ENABLED.

In the basic .env configuration, complete the General settings section:

APP_URL="http://localhost/"
APP_NAME="Application Name"
APP_EMAIL="[email protected]"

Next, configure: Cache settings, Database settings, Mailer settings, API settings.

Note: After launching the application, set CACHE_ENABLED=true to enable caching and speed up the page.

Autoloading

Manual installation makes the framework independent of other tools, equipped with its own autoloading. Executing the composer install command will automate the framework, create a Composer autoloader, and install selected packages, such as email sending and development packages. After executing the command, the framework will work with Composer.

Installing with Composer

If you prefer to install with Composer or your project requires additional packages:

git clone https://github.com/designbymalina/dbmframework.git

If you want to use external libraries, you can use Composer:

composer install

Installing with Composer will create autoloading and download all dependencies.

Note: After installing the application with Composer, the necessary dependencies will be available, and the libraries directory can be removed.

Routing

Classic routing is defined in the file: application/routes.php.

Example:

$router->get('/path', [NameController::class, 'methodName'], 'route_name');

You define REST API Routing in the application/api.php file.

Example:

$router->get('/api/path', [NameApiController::class, 'methodName'], 'api_route_name');

Dependency Injection

DbM Framework uses a lightweight DI container, compliant with PSR-11, which offers two modes of operation:

  • Manual configuration (recommended)

You register all dependencies explicitly in the application/services.php file:

$container->set(Database::class, fn() => new Database($config));
$container->singleton(Request::class, fn() => new Request());

This mode guarantees full control over dependencies and performance.

  • Semi-automatic configuration (available)

In many cases, the framework can recognize and inject a dependency based on the parameter type in the controller or service constructor:

public function __construct(Mailer $mailer) { ... }

If the class is known and PSR-4 autoload-compliant, it will be injected correctly. However, explicit service registration is recommended for full predictability and stability.

This compromise combines the simplicity of manual DI with the flexibility of automatic detection—without the cost of full reflection found in heavy frameworks.

Template Engine

The framework uses a built-in template engine by default. You can freely replace it with something like Twig.

Why use DbM View Engine over the most popular engines:

Cechy Twig Blade DbM View Engine
Szybkość średnia dobra najwyższa
PHP-friendly ⚠️ ✅ programista wie co robi
Filtry tak tak ✅ proste i rozszerzalne
Pluginy trudne brak ✅ runtime callbacks
Dziedziczenie bloków tak tak ✅ + append/prepend
Cache tak tak ✅ klasy OPC
Sandbox tak brak ✅ opcjonalny
Zależności duże średnie ✅ niezależny
Waga >400KB ~200KB ~50KB

In tests with CACHE=TRUE, the results achieved were similar to those of Native PHP.

=== TEMPLATE ENGINE BENCHMARK - benchmark.phtml ===

MODE AVG(ms) MEDIAN MIN MAX STD
CACHE=FALSE 1.31 1.29 1.17 1.67 0.09
CACHE=TRUE 0.17 0.16 0.16 0.31 0.02
Native PHP 0.15 0.14 0.14 0.18 0.01

Conclusion: DbM View Engine (cache=true) is almost as fast as pure PHP, confirming its performance.

Templates are located in the templates/ directory.

Command Console

A lightweight and fast CLI for CRON and DEV tasks. It provides a simple way to run background or maintenance tasks directly from the command line with a lightweight and self-contained implementation. Console commands are executed via the file: bin/dbm.

Available commands:

php bin/dbm list
php bin/dbm command example (for ExampleCommand)
php bin/dbm worker example (for ExampleWorker)

Additional Information

In a production environment (on a remote server), the domain must point to the public/ directory, as it serves as the document root. If you are using a local environment (localhost), configure the .htaccess files in both the project root and the public/ folder. For remote servers where the domain already points directly to the public/ directory, the application typically requires no further .htaccess configuration.

Ensure that open_basedir does not block access to directories. Depending on your server configuration, it may be necessary to disable this restriction in the PHP settings. This security feature, known as "site separation," can block access to files outside the domain's document root, preventing the application from functioning correctly.

After launching the application, enable the cache (CACHE_ENABLED=true) to speed up the website.

When using DBM CMS, also ensure that the data/ directories have the appropriate write permissions.

IMPORTANT! Please retain the footer: "Created with DbM Framework". The link should remain intact. Thank you for supporting the project! By maintaining the link in the footer, you help develop the free, open-source framework and support its development and the community of independent PHP developers.

Documentation:

Introduction
Creating first Controller and Service
Application Programming Interface (api.php)
Command console (console.php)
Dependency Injection - DI (services.php)
Environment configuration (.env)
Middleware (middleware.php)
Routing (routes.php)
Request
Response
TemplateEngine
TemplateFeature
Templates

--- DbM CMS ---

Quick Start