malinichevvv/lift-php
Composer 安装命令:
composer require malinichevvv/lift-php
包简介
A fast, minimal PHP micro-framework — PSR-7/11/15, autowiring DI, routing, and zero config
关键字:
README 文档
README
Lift — a fast, minimal PHP micro-framework
Lift is a PHP 8.1+ micro-framework built around PSR standards. It gives you a router, an autowiring DI container, PSR-7 request/response objects, and a PSR-15 middleware pipeline — everything you actually need, nothing you don't.
Installation
composer require malinichevvv/lift-php
Quick start
<?php require 'vendor/autoload.php'; use Lift\App; use Lift\Http\Request; use Lift\Http\Response; $app = new App(); $app->get('/', fn() => ['message' => 'Hello, World!']); $app->get('/users/{id:\d+}', function (Request $req) use ($repo) { $user = $repo->find((int) $req->param('id')); return $user ?? throw new \Lift\Exception\NotFoundException(); }); $app->post('/users', function (Request $req) use ($repo) { $data = $req->validate([ 'name' => 'required|string|max:255', 'email' => 'required|email', ]); return Response::json($repo->create($data), 201); }); $app->run();
No config files. No service providers. No magic — just PHP.
Starter project
Prefer a ready-made project layout over a single file? Scaffold one with Composer:
composer create-project malinichevvv/lift-skeleton myapp cd myapp && composer serve
lift-skeleton is a small URL-shortener microservice — a working example of attribute routing, request validation, migrations, a cache layer, per-route middleware, a custom console command, and feature tests.
What's included
| Feature | |
|---|---|
| Router | Named routes, regex constraints, groups, attribute routing |
| DI Container | PSR-11, full autowiring, circular dependency detection |
| HTTP | Immutable PSR-7 Request/Response, cookies, file uploads |
| Middleware | PSR-15 pipeline, global / group / per-route |
| Database | Query builder, migrations, models, transactions, pessimistic locks |
| Validation | 60+ rules, custom messages, FormRequest |
| Console | CLI framework, scaffolding generators, interactive REPL |
| Views | Template engine with layouts, partials, and asset helpers |
| Queue | Sync, Database, Redis, AMQP drivers + worker |
| Cache | PSR-16, File, Redis, Database backends |
| Events | PSR-14 dispatcher |
| HTTP Client | Fluent wrapper for ext-curl |
| Auth/Crypto | JWT, HMAC, Bcrypt, AES-256-GCM |
| OpenAPI | Attribute-driven spec generation |
| SSE | Server-Sent Events response |
| Testing | Built-in TestCase with HTTP helpers |
| Debug | Dev toolbar with SQL, request, performance, and error tabs |
Routing
$app->get('/path', $handler); $app->post('/path', $handler); $app->put('/path', $handler); $app->patch('/path', $handler); $app->delete('/path', $handler); $app->any('/path', $handler); $app->map(['GET', 'POST'], '/path', $handler);
Any callable works as a handler — closure, [Class::class, 'method'], invokable class, or function name. Dependencies are autowired from the container automatically.
// Regex-constrained parameter $app->get('/posts/{id:\d+}', fn(Request $req) => ['id' => (int) $req->param('id')]); // Named route + URL generation $app->get('/users/{id}', $h)->name('users.show'); $app->url('users.show', ['id' => 42]); // → /users/42 // Group with shared prefix + middleware $app->group('/api/v1', function ($g) { $g->get('/users', [UserController::class, 'index']); $g->post('/users', [UserController::class, 'store']); $g->get('/users/{id}', [UserController::class, 'show']); })->middleware(AuthMiddleware::class);
DI Container
// Bind interface → concrete class (autowired) $app->bind(UserRepositoryInterface::class, MySQLUserRepository::class); // Singleton factory $app->singleton(Connection::class, fn() => Connection::fromEnv()); // Pre-built instance $app->instance(Config::class, $config); // Inject anywhere via type-hint — Lift resolves it automatically $app->get('/users', function (Request $req, UserRepository $repo) { return $repo->all(); });
Error handling
use Lift\Debug\ErrorRenderer; // Content-negotiating handler — JSON for API clients, HTML for browsers $app->onError(ErrorRenderer::auto()); // Or custom $app->onException(\Lift\Exception\NotFoundException::class, fn() => Response::json(['error' => 'Not found'], 404) );
Testing
App::handle(Request): Response never touches $_SERVER or php://input, so tests need no HTTP server:
use Lift\Testing\TestCase; final class UserApiTest extends TestCase { public function testCreateUser(): void { $res = $this->post('/users', ['name' => 'Alice', 'email' => 'alice@example.com']); $this->assertStatus(201, $res); $this->assertJsonContains(['name' => 'Alice'], $res); } }
Requirements
- PHP 8.1+
- Composer
Optional extensions unlock specific features (ext-redis, ext-pcntl, ext-curl, ext-pdo). The core framework works without any of them.
Documentation
Full docs with examples for every feature: getlift.dev
License
MIT © Vladyslav Malinichiev
malinichevvv/lift-php 适用场景与选型建议
malinichevvv/lift-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21 次下载、GitHub Stars 达 2, 最近一次更新时间为 2026 年 05 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「php」 「http」 「router」 「middleware」 「micro-framework」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 malinichevvv/lift-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 malinichevvv/lift-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 malinichevvv/lift-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
repository php library
http客户端
Easily add Excepct-CT header to your project
Build mini web servers in PHP for testing
Alfabank REST API integration
统计信息
- 总下载量: 21
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 28
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-15