craftphp/mini-skeleton

This is a mini skeleton of Craft framework.

0.1.0-alpha 2025-09-17 06:14 UTC

This package is auto-updated.

Last update: 2025-09-20 16:16:50 UTC


README

CraftMini is a minimalist PHP framework designed for small projects, learning, or as a foundation for personal framework development.

Features

  • Routing: Flexible routing system, supporting groups, middleware, named routes, RESTful and API routes.
  • View Engine: Supports multiple view engines, default is PHP, easily extendable to Blade, Twig, etc.
  • Session & Flash: Manage sessions, convenient flash messages for one-time notifications.
  • Database Layer:
    • Supports multiple database systems (MySQL, SQLite).
    • Supports multiple drivers (mysqli, sqlite3, PDO).
    • Adapter pattern for connections and queries.
    • Query Builder generates dynamic SQL, separated from the adapter.
    • Record Mapper CRUD for each table.
  • Error & Exception Handling: Error reporting, logging, runtime, parsing, separate exceptions.
  • Helper: Many utility functions for debugging, var_dump, helper function.
  • Environment Configuration: Read environment variables from .env, supported by TinyEnv.
  • Security: Supports secure sessions, maintenance mode, security headers, tokens generation (easily extendable).

Basic Usage

Routing:

$router = new Craft\Application\Router();
$router->get('/', [App\Controller\HomeController::class, 'index']);
$router->runInstance();

Controller:

class HomeController extends Controller {
    public function index() {
        return $this->render('home', ['message' => 'Hello!']);
    }
}

Database:

$test = new User();
$allUsers = $test->all(); // Get all users with Mapper

View:

echo Craft\Application\View::render('home', ['message' => 'Hello!']);

Session & Flash:

Craft\Application\Session::flash('msg', 'Success!'); // Set flash message
echo Craft\Application\Session::getFlash('msg'); // Get and clear flash message

System Requirements

Installation

  1. Clone the repository:
composer install
  1. With Composer, you can create a new project:
composer create-project craftphp/mini-skeleton your-project-name

Contribution

Fork, create a pull request or open an issue to contribute ideas or report bugs. CraftMini is suitable for those who want to learn how to build a PHP framework from scratch or as a foundation for small projects, demos, and experimenting with new ideas.