rapo/framework
Composer 安装命令:
composer require rapo/framework
包简介
A modern, lightweight PHP framework designed to bring the Next.js developer experience to the PHP world.
README 文档
README
RapoPHP is a modern, lightweight PHP framework designed to bring the Next.js developer experience to the PHP world. It moves away from traditional MVC patterns in favor of a component-centric architecture, file-based routing, and built-in reactivity.
⚠️ Warning: RapoPHP is in early development. APIs and features may change significantly and security improvements are ongoing. Use at your own risk.
Key Modern Features
Zero-Config File-based Routing (Next.js App Router Style)
- Folder-Based URL Segments: Your directory structure in
src/Pagesdirectly maps to URLs. - Routable Files: A route is only public if it contains a
Page.phporIndex.php. Colocate other files (components, tests) safely. - Private Folders: Prefix folders with
_(e.g.,_components) to opt them out of routing. - Route Groups: Wrap folders in
()(e.g.,(marketing)) to organize routes without affecting the URL. - Dynamic Routes: Full support for
[slug]and catch-all[...slug]segments. - Special Files: Built-in support for
Layout.php,Template.php,Error.php,NotFound.php,Loading.php, andAction.phpat any level. - Hierarchical Layouts & Middleware: Layouts and Middleware nest automatically following the folder structure.
- Server Actions: Define server-side logic in
Action.phpto handle form submissions directly in your route folder.
Component-Centric UI
- Pages as Components: Forget controllers. A page is just a PHP class extending
Component. - JSX-style PHP: Use the
h()helper for a declarative way to build HTML. - Functional Hooks:
useRouter(): Access routing data and navigation.useHead(): Declarative metadata management.useState(): Persisted state across requests.useForm(): Simplified form handling and validation.useSession(): Easy session management.useCache(): Access to the built-in caching layer.
- Nested Layouts: Intuitively wrap pages with layouts at any level.
Performance & DX
- Rapo-Live: Livewire-style server-side reactivity for interactive components.
- Data Fetching: Built-in
getServerSidePropsfor pre-rendering data. - ISR & Caching: Incremental Static Regeneration support for blazing fast load times via the built-in
Cacheservice. - Modern CLI: Scaffolding for pages, components, models, middleware, and server actions.
- Image Optimization: Built-in
Imagecomponent for lazy-loading and optimization. - Mail Engine: Professional email handling using Symfony Mailer, powered by Rapo Components.
- Context Debugger: A built-in floating badge in debug mode to inspect component props and route hierarchy.
- Quality Tools: Built-in
dd()anddump()helpers via Symfony Var-Dumper.
Modern Data & Auth
- Active Record ORM: A fluent way to interact with your database.
- Automatic Migrations: Define your schema in models and sync effortlessly.
- Auth Scaffolding: Get a full authentication system running in seconds.
- Storage Abstraction: Simplified file management with
storage()helper anduseStorage()hook. - Background Queues: Handle heavy tasks out-of-process with the SQLite-based
queue()system. - Attribute-based Validation: Cleanly validate requests using PHP 8 Attributes:
#[Validate(['email' => 'required|email'])].
Rapo-Only Unique Features
Hierarchical i18n
Translations that follow your folder structure. Place translation.php in any route folder, and use the useTranslation() hook. It automatically merges translations from the current page up to the root.
Automatic Page-to-API Mirroring
Every page is an API. Request any page with Accept: application/json and RapoPHP will return the props and getServerSideProps data as JSON instead of HTML.
Markdown-as-Routes
Create docs effortlessly. Create Page.md in any route folder, and RapoPHP will automatically parse and render it.
Installation
The recommended way to install RapoPHP is via Composer:
composer require rapo/framework php vendor/bin/rapo project:init
CLI Commands
After initializing your project, you can use the Rapo CLI:
# Start the development server php vendor/bin/rapo serve # Create a dynamic page: src/Pages/blog/[slug]/Page.php php vendor/bin/rapo make:page blog/[slug] # Create a new component php vendor/bin/rapo make:component Navbar # Create an API route php vendor/bin/rapo make:api-route status # Create a Server Action php vendor/bin/rapo make:action contact # Run migrations php vendor/bin/rapo migrate # Start queue worker php vendor/bin/rapo queue:work
Advanced Features
Server Actions & Validation
Handle forms with zero-config using Action.php and declarative validation:
namespace App\Pages\contact; use Rapo\Http\Attributes\Validate; class Action { #[Validate(['email' => 'required|email', 'msg' => 'required'])] public function handle($request) { // Logic here... return redirect('/thanks'); } }
Background Jobs
Keep your app fast by offloading heavy tasks:
// Dispatch to queue queue(SendEmailJob::class, ['to' => 'user@example.com']);
Storage
Easily manage files across different environments:
storage()->put('uploads/photo.jpg', $binaryData); $url = storage()->url('uploads/photo.jpg');
Built with ❤️ for PHP developers who love modern workflows.
rapo/framework 适用场景与选型建议
rapo/framework 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「php」 「components」 「file-based-routing」 「nextjs-style」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rapo/framework 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rapo/framework 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rapo/framework 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
Web Font Loader gives you added control when using linked fonts via @font-face.
Ariadne Component Library: xml writer and parser Component
Ariadne Component Library: Cache Component
Ariadne Component Library: hierarchical configuration management Component
Ariadne Component Library: user and group rights management Component
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 29
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-24