neoisrecursive/inertia-tempest
Composer 安装命令:
composer require neoisrecursive/inertia-tempest
包简介
A inertia adapter for the tempestphp framework
README 文档
README
installation
composer require neoisrecursive/inertia-tempest
Setup
It should be very familiar if you have used inertia before, with some small differences, for example:
- No configuration is done in the middleware, use the the config file, a provider class or your own middleware to set your "globally-shared-props".
- No automatic redirect back handling in non get requests, since all tempest routes must return a response you have to return your own
Backresponse. - Includes all validation errors for each field by default, instead of just the first one.
We provide an installer that you can use to set up some of the boilerplate code, but you can also do it manually.
Installer
First run the tempest vite installer (the inertia installer assumes you use vite):
./tempest install vite
Then you can run the inertia installer:
./tempest install inertia
Then all you have to do is to follow the instructions in the terminal. The only manual step is to add the vite plugin for your fe-framework to the vite config file.
Manual setup
If you don't want to use the installer, you can do the following steps manually:
Backend
If you use the default config, a view called app.view.php is required. That view will then be rendered as an NeoIsRecursive\Inertia\Views\InertiaBaseView and to render the inertia element you just do:
<x-inertia />
Frontend
Install the bundler of your choice, since tempest comes with a vite installer, that is very much recommended. Tempest vite docs.
When that is done, you can go on to install your prefered inertia client by following the guide on inertia's official site here
Usage
It is pretty similar to the Laravel adapter, except that to return an Inertia respone, you return a Component instance - like in your other Tempest routes.
use Tempest\Http\Get; use NeoIsRecursive\Inertia\Http\Component; final class ReviewController { #[Get(uri: '/reviews/{review}')] public function show(Review $review): Component { return new Component('reviews/show', [ 'review' => $review, ]); } }
Configuration
This is the default config:
<?php use NeoIsRecursive\Inertia\DefaultSharedPropResolver; use NeoIsRecursive\Inertia\InertiaConfig; use NeoIsRecursive\Inertia\ManifestVersionResolver; use function Tempest\root_path; return new InertiaConfig( /** * The view that inertia should render on the first request */ rootView: 'app.view.php', /** * Version resolver, if you use vite for example you probably want to use the default here, * or you can add a custom one to maybe get from enviroment variables etc. * * default path: public/build/manifest.json */ versionResolver: new ManifestVersionResolver(), /** * Props that should be included in "all" requests, the default is errors and the authenticated user */ sharedProps: [ 'user' => new AlwaysProp(fn(Authenticator $auth) => $auth->currentUser()), 'errors' => new AlwaysProp(fn(ResolveErrorProps $errors) => $errors->resolve()), ] );
neoisrecursive/inertia-tempest 适用场景与选型建议
neoisrecursive/inertia-tempest 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.44k 次下载、GitHub Stars 达 11, 最近一次更新时间为 2024 年 11 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 neoisrecursive/inertia-tempest 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 neoisrecursive/inertia-tempest 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 5.44k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-11-01