DVC - Dave's View Controller Framework
DVC is a lightweight PHP framework designed for rapid web development with sensible defaults and minimal configuration.
Quick Start
-
Create your
composer.json
The application relies on the composer autoload features,
this (very) basic composer.json file tells the autloader where to look
for this application and installs bravedave/dvccomposer.json
{ "require": { "bravedave/dvc": "*" }, "autoload": { "psr-4": { "": "src/app/" } } }
-
Installation:
composer u
-
Create Application Structure:
vendor/bin/dvc make::application
This creates:
src/app/application.php
(main application file)- Default folder structure structure
-
Run Your Application:
vendor/bin/dvc serve
Default Structure
src/
├── app/
│ └── application.php # Main application file
└── controller/
├── home.php # Default controller
└── ... # Additional controllers
Key Concept
Controller Routing
DVC uses a simple, convention-based routing system:
- URL Path:
/products
- Maps to:
src/controller/products.php
Example controller (src/controller/products.php
):
<?php
class products extends bravedave\dvc\controller {
// _index is the default view
protected function _index() {
$this->data = (object)[
'title' => $this->title = config::label,
];
$this->renderBS5([
'aside' => fn() => $this->load('blank'),
'main' => fn() => printf('i am %s', __CLASSNAME__ )
]);
}
}
Next Steps
- Modules & Controllers - Deep dive into creating and organizing modules
- Database Strategy - Database Access with DAO & DTO
- View System - PHP/Markdown
- Tutorial - a simple tutorial
- Request Handling - POST/GET separation and API responses