desert-dionysus/inertia-wordpress
Composer 安装命令:
composer require desert-dionysus/inertia-wordpress
包简介
The modernized WordPress adapter for Inertia.js v2.0
README 文档
README
A modernized Inertia.js server-side adapter for WordPress, aligned with Inertia.js v2.0+ protocol.
Note: This is a fork of the excellent work by Andrew Rhyand (BoxyBird). While the core philosophy remains the same, this version has been modernized for PHP 8.2+ and adds support for the latest Inertia.js features like Deferred Props, Merge Props, and more.
Installation
Install the package via composer:
composer require desert-dionysus/inertia-wordpress
Acknowledgements & Resources
This project is a fork of boxybird/inertia-wordpress. We highly recommend checking out Andrew's original work and examples:
- Original Repository: boxybird/inertia-wordpress
- Example Movie CPT Project: Theme Repository | Demo Site
Root Template Example
Location:
/wp-content/themes/your-theme/app.php(orlayout.php)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <?php wp_head(); ?> </head> <body> <?php bb_inject_inertia(); ?> <?php wp_footer(); ?> </body> </html>
The inertia() Helper
This fork introduces a global inertia() helper function that provides a fluent API similar to Laravel's adapter.
// Render a component return inertia('Index', ['posts' => $posts]); // Chainable methods return inertia() ->version('1.0.0') ->share('key', 'value') ->render('Index', $props);
Core Features
Inertia Responses
use DesertDionysus\Inertia\Inertia; // Using the Class return Inertia::render('Posts/Index', [ 'posts' => $posts, ]); // Or using the helper return inertia('Posts/Index', [ 'posts' => $posts, ]);
Shared Data
Shared data is automatically included in every Inertia response.
inertia()->share('site_name', get_bloginfo('name')); // Shared Closures are only executed if they are included in the response inertia()->share('auth', function () { return is_user_logged_in() ? wp_get_current_user() : null; });
Always Props (v2.0)
Props wrapped in always() will be included in every response, even during partial reloads where they weren't specifically requested.
return inertia('Profile', [ 'user' => $user, 'social_links' => Inertia::always($links), ]);
Deferred Props (v2.0)
Deferred props allow you to load heavy data asynchronously after the initial page load.
return inertia('Dashboard', [ 'stats' => Inertia::defer(fn() => get_heavy_stats()), 'logs' => Inertia::defer(fn() => get_logs(), 'activity-group'), ]);
Merge Props (v2.0)
Useful for infinite scrolling or pagination.
return inertia('Blog', [ 'posts' => Inertia::merge(fn() => get_next_page_posts()), ]);
External Redirects
Handles full-page redirects, even during Inertia AJAX requests.
return Inertia::location('https://external-site.com');
WordPress Integration
Automatic Nonce Injection
This adapter automatically includes a wp_rest nonce in every response under the nonce prop, simplifying CSRF protection for your API calls.
Flash Messages & Validation Errors
Easily pass flash messages or validation errors that will be automatically shared via the flash and errors props.
// In your "Controller" inertia()->flash('success', 'Post updated!'); inertia()->withErrors(['title' => 'Title is required']); return Inertia::location(get_permalink($post_id));
Asset Versioning
// Automatically version from Vite manifest Inertia::versionFromVite(get_stylesheet_directory() . '/dist/manifest.json'); // Or from any specific file Inertia::versionFromFile(get_stylesheet_directory() . '/style.css'); // Or manually Inertia::version('v1.2.3');
Configuration
Root Template File Override
add_action('init', function () { Inertia::setRootView('layout.php'); });
Inertia Docs
desert-dionysus/inertia-wordpress 适用场景与选型建议
desert-dionysus/inertia-wordpress 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 01 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「plugin」 「wordpress」 「react」 「vue」 「inertia.js」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 desert-dionysus/inertia-wordpress 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 desert-dionysus/inertia-wordpress 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 desert-dionysus/inertia-wordpress 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
Async Reactive Postgres Driver for PHP (Non-blocking)
Laravel integration for blade-to-react
A simple, flexible Laravel package for adding polymorphic reactions to any model. React with any text: like, love, care, or anything you want.
Plugin for YOURLS. Default tools to use in some laemmi plugins
This library tries to create a simple promise factory standard while waiting for a psr.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-18