Skip to content

Latest commit

 

History

History
138 lines (109 loc) · 5.62 KB

File metadata and controls

138 lines (109 loc) · 5.62 KB

NM Base Framework V2

NM Base Framework V2

A lightweight PHP 8.2 MVC framework, built from scratch and hardened with best-in-class Composer packages.

PHP 8.2 MVC v2.0.0 MIT License


About

NM Base Framework V2 is a custom PHP MVC framework built around clean OOP principles: routing, an ORM-backed database layer, queues, task scheduling, a section-based view engine, and a hardened security stack — all under one roof.

Version 2 keeps the original hand-rolled core where it already worked well (routing, scheduler, view engine, queues) and replaces the parts that benefit most from mature, well-audited packages: the ORM, HTTP layer, cryptography, validation, and logging.

Features

  • 🔀 Routing — named routes compiled to regex, dispatched through a Symfony HttpFoundation–backed Request/Response layer
  • 🗄 Eloquent ORM — models, relationships, migrations and pagination via illuminate/database
  • ⚙️ Job Queues — Database, Redis, or Sync drivers with unique job guards
  • 🕑 Task Scheduler — cron-style, fluent PHP API, Carbon-aware date handling
  • 🖼 View Engine — section-based templates with layout inheritance
  • 🔐 Cryptography — authenticated encryption via Halite (libsodium) and defuse/php-encryption
  • 🪪 JWT & Tokens — stateless auth via web-token/jwt-library and firebase/php-jwt
  • 🛡 CSRF & Security — token validation via symfony/security-csrf, plus a dedicated Authorization layer
  • ✅ Validation — declarative rule chains via respect/validation, RFC-compliant email checks
  • 📡 HTTP Client & Logging — Guzzle for outbound requests, PSR-3 logging via Monolog
  • 🌍 i18n — translation catalogs via symfony/translation
  • 📁 Filesystem — file discovery and operations via Symfony Filesystem/Finder
  • 🧩 Container & Events — PSR-11 service container, event dispatcher via illuminate/events

Requirements

  • PHP ^8.2
  • Composer
  • MySQL / PostgreSQL / SQLite (any driver supported by illuminate/database)
  • Redis (optional — required only for the Redis queue driver)

Installation

git clone https://github.com/nooreddinemaiza/nm-base-framework-v2.git
cd nm-base-framework-v2
composer install
php -S localhost:8000 -t public

Project Structure

App/            → Controllers, Eloquent Models, database migrations & seeders
config/         → .env, app.php, database.php, mailer.php
Core/           → Framework internals (Routing, Database, Security, Queue, Scheduler, ViewEngine…)
public/         → Entry point (index.php) and static assets
resources/      → Layouts, views, partials, components
routes/         → Route definitions (web.php)
storage/        → Logs, cache, framework runtime files, uploads
vendor/         → Composer dependencies

Dependencies

Package Version Purpose
vlucas/phpdotenv * .env loading
monolog/monolog ^3.9 PSR-3 structured logging
guzzlehttp/guzzle * Outbound HTTP client
symfony/var-dumper * Debug dumping
symfony/http-foundation ^7.3 Request / Response abstraction
psr/container ^2.0 Service container interface
psr/log ^3.0 Logger interface
symfony/filesystem 6.0 Filesystem operations
symfony/finder 6.0 File discovery
league/mime-type-detection 1.11 MIME detection for uploads
respect/validation 2.2 Declarative validation rules
symfony/translation 6.0 i18n / translation catalogs
egulias/email-validator 4.0 RFC-compliant email validation
paragonie/constant_time_encoding ^2.7 Timing-safe encoding
paragonie/halite ^5.1 Libsodium-based encryption
defuse/php-encryption 2.4 Authenticated symmetric encryption
web-token/jwt-library 3.3 JWS / JWE / JWK toolchain
firebase/php-jwt 6.0 Lightweight JWT encode/decode
psr/cache 3.0 Cache pool interface
nesbot/carbon ^3.9 Date & time handling
illuminate/database ^12.18 Eloquent ORM & schema builder
paragonie/hidden-string ^2.2 Prevent secrets leaking in dumps/logs
symfony/security-csrf ^7.3 CSRF token management
illuminate/pagination ^12.18 Query result pagination
illuminate/events ^12.18 Event dispatcher

Usage Example

// Routes/web.php
$router->get('/users/{id}', [UserController::class, 'show'])->name('users.show');
// App/Controllers/UserController.php
class UserController
{
    public function show(Request $request, int $id): Response
    {
        $user = User::findOrFail($id);

        return $this->view->render('users/show', ['user' => $user]);
    }
}

Roadmap

  • Redis-backed cache pool (psr/cache implementation)
  • CLI scaffolding commands (make:controller, make:model, make:migration)
  • First-party test suite with PHPUnit
  • API resource / transformer layer

Contributing

Issues and pull requests are welcome. Please open an issue first to discuss any significant change.

License

Released under the MIT License.

Author

Built by NM.