akrbdk / php-mvc-framework-core
There is no license information available for the latest version (v1.0.6) of this package.
Package info
github.com/okarabudka/php-mvc-framework-core
pkg:composer/akrbdk/php-mvc-framework-core
v1.0.6
2023-05-18 20:05 UTC
Requires
None
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A minimal, self-written PHP MVC framework core distributed as a Composer package.
Context
Learning project built in May 2023. The framework code was first written inside the php-mvc-framework application and then extracted into this reusable library, which is published on Packagist as akrbdk/php-mvc-framework-core.
Not tested in production. Use it at your own risk.
Features
Applicationcontainer with a static instance, request lifecycle and event listeners (beforeRequest,afterRequest)Routerwith GET and POST routes and controller/action callbacksRequestandResponsewrappersControllerbase class with layouts and middleware registrationAuthMiddlewarethat restricts actions to logged-in usersModelwith rule-based validation:required,email,min,max,match,uniqueDbModel/UserModelwithsave()andfindOne()on top of PDODatabasewith a simple migration runner that tracks applied migrationsSessionwith flash messagesViewthat renders templates inside layouts- Form helpers (
Form,InputField,TextareaField) that output Bootstrap-style markup with validation errors NotFoundExceptionandForbiddenException
Tech stack
- PHP (no runtime dependencies in
composer.json; the demo application targets PHP 8.1) - PDO
- Composer, PSR-4 autoloading
Architecture
- Classic MVC with a front controller: the application creates
Application, registers routes and callsrun(). - Global access to services through
Application::$app(router, request, response, session, view, db, current user). - Active-record style models: a model defines
tableName(),attributes()andprimaryKey(),DbModelbuilds the SQL. - Sub-namespaces:
db/(database and models),form/(form rendering),middlewares/,exception/. - Namespace:
Akrbdk\PhpMvcCore.
Getting started
composer require akrbdk/php-mvc-framework-core
See php-mvc-framework for a complete application that uses this package.
Testing
There are no automated tests.
Status
Finished learning project (2023), not maintained.
License
MIT, see LICENSE.