nitier/framework
最新稳定版本:v0.6.2
Composer 安装命令:
composer require nitier/framework
包简介
A PHP framework for building web applications.
README 文档
README
Minimalist PHP 8.4 framework that embraces the PSR ecosystem while keeping the core tiny. Features:
- PSR-7 HTTP messages and PSR-15 middleware pipeline
- Attribute-based routing and DI powered by PHP-DI
- Reusable response helpers (JSON, HTML, redirect, etc.)
- Debug overlay for HTML responses in dev mode
- Optional session and cookie utilities
- Example application under
examples/test-app/and comprehensive docs underdocs/
Installation
composer require nitier/framework
Or clone the repository for development:
git clone https://github.com/nitier/framework.git
cd framework
composer install
Quick Start
- Copy
examples/test-app/as a starting point or require the package in your existing project. - In
public/index.phpbootstrap the kernel and point to your app directory:
use Framework\Kernel; require __DIR__ . '/../vendor/autoload.php'; $kernel = new Kernel(); $kernel->loadApplication(__DIR__ . '/../examples/test-app'); $kernel->handle();
- Add routes/controllers under
examples/test-app/src/Http/Controller/using attribute routes:
use Framework\Http\Routing\Attribute\Route; use Framework\Http\Message\JsonResponse; class ApiController { #[Route(methods: ['GET'], path: '/api/status')] public function status(): JsonResponse { return new JsonResponse(['status' => 'ok']); } }
- Configure global middleware, services, and settings via PHP files inside
config/and your app'sconfig/directory.
Session & Cookie Helpers
use Framework\Http\Session\SessionManager; use Framework\Http\Cookie\CookieJar; $session = new SessionManager(); $session->set('user_id', 42); $cookies = new CookieJar(); cookies->queue('token', 'abc', ['httpOnly' => true]);
Add StartSessionMiddleware and CookieQueueMiddleware to your global middleware list to automate lifecycle management.
Debug Mode
Enable debug by storing kernel.mode.debug => true in the container. HTML responses will include a floating diagnostic panel with request attributes, environment snapshot, and metrics.
Testing & Quality
composer testcomposer cscomposer stan
All tests run inside PHPUnit; some session tests use isolated processes.
Documentation
Extensive docs live in the docs/ directory covering routing, middleware, responses, templates, sessions, and testing. View them online or serve them using the example app at /docs.
License
MIT License. See LICENSE for details.
统计信息
- 总下载量: 15
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2025-09-29