zb-framework / core
A minimalistic php MVC framework core.
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Forks: 0
pkg:composer/zb-framework/core
Requires
- zb-framework/db-wrapper: ^1.0.0
- zb-framework/router: ^1.0.1
README
ZBF-Core is a minimalistic PHP MVC framework designed as a Composer package. It provides a simple and lightweight structure for building web applications.
Usage
Once installed, you can use ZBF-Core to create and run your application.
Basic Example
Create an entry point (e.g., public/index.php) and initialize the framework:
<?php
// Load Composer's autoloader
require_once __DIR__ . '/../../vendor/autoload.php';
use ZbFramework\Core\App;
$app = new App(
__DIR__ . '/', // Webroot/public directory
__DIR__ . '/../App/' // App directory
);
$app->registerRoute(
'GET', // HTTP method (use "ALL" or "*" for all methods)
'/', // Path (can contain URL parameters like /article/{article_id})
Admin\App\Controllers\DashboardController::class, // Controller class
'index' // Action method
);
$app->run();
Routing
You can register routes using $app->registerRoute(). It takes the following parameters:
- HTTP Method: e.g.,
GET,POST,PUT,DELETE,ALL. - Path: The route URL, which can contain parameters (e.g.,
/user/{id}). - Controller Class: The fully qualified name of the controller handling the request.
- Action Method: The method within the controller that will be executed.
Directory Structure
project-root/
│── App/
│ ├── Controllers/
│ │ ├── DashboardController.php
│ ├── Models/
│ ├── Templates/
│ │ ├── Layouts/
│ │ ├── Elements/
│ │ ├── Dashboard/
│ │ │ ├── index.php
│── public/
│ ├── index.php
│── vendor/
│── composer.json
Contributing
Feel free to contribute by submitting pull requests or reporting issues.
License
This project is licensed under the GPL-3.0 License.