{"id":49703090,"url":"https://github.com/yii2-extensions/inertia","last_synced_at":"2026-05-08T08:12:54.537Z","repository":{"id":348777889,"uuid":"1196150046","full_name":"yii2-extensions/inertia","owner":"yii2-extensions","description":"Inertia.js server-side adapter for Yii2 page rendering, shared props, partial reloads, flash/error mapping, and asset version handling.","archived":false,"fork":false,"pushed_at":"2026-04-24T14:43:25.000Z","size":140,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-24T16:40:52.067Z","etag":null,"topics":["inertia","inertiajs","php","server-driven-ui","server-side-rendering","single-page-applications","spa","yii2"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yii2-extensions.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["terabytesoftw"]}},"created_at":"2026-03-30T12:23:06.000Z","updated_at":"2026-04-24T14:43:27.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/yii2-extensions/inertia","commit_stats":null,"previous_names":["yii2-framework/inertia","yii2-extensions/inertia"],"tags_count":1,"template":false,"template_full_name":"yii2-extensions/template","purl":"pkg:github/yii2-extensions/inertia","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yii2-extensions%2Finertia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yii2-extensions%2Finertia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yii2-extensions%2Finertia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yii2-extensions%2Finertia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yii2-extensions","download_url":"https://codeload.github.com/yii2-extensions/inertia/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yii2-extensions%2Finertia/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32772192,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T02:36:36.067Z","status":"ssl_error","status_checked_at":"2026-05-08T02:36:07.210Z","response_time":54,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["inertia","inertiajs","php","server-driven-ui","server-side-rendering","single-page-applications","spa","yii2"],"created_at":"2026-05-08T08:12:53.371Z","updated_at":"2026-05-08T08:12:54.521Z","avatar_url":"https://github.com/yii2-extensions.png","language":"PHP","funding_links":["https://github.com/sponsors/terabytesoftw"],"categories":[],"sub_categories":[],"readme":"\u003c!-- markdownlint-disable MD041 --\u003e\n\u003cp align=\"center\"\u003e\n    \u003cpicture\u003e\n        \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://www.yiiframework.com/image/design/logo/yii3_full_for_dark.svg\"\u003e\n        \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://www.yiiframework.com/image/design/logo/yii3_full_for_light.svg\"\u003e\n        \u003cimg src=\"https://www.yiiframework.com/image/design/logo/yii3_full_for_light.svg\" alt=\"Yii Framework\" width=\"80%\"\u003e\n    \u003c/picture\u003e\n    \u003ch1 align=\"center\"\u003eInertia\u003c/h1\u003e\n    \u003cbr\u003e\n\u003c/p\u003e\n\u003c!-- markdownlint-enable MD041 --\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/yii2-extensions/inertia/actions/workflows/build.yml\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/yii2-extensions/inertia/build.yml?style=for-the-badge\u0026logo=github\u0026label=PHPUnit\" alt=\"PHPUnit\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://dashboard.stryker-mutator.io/reports/github.com/yii2-extensions/inertia/main\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://img.shields.io/endpoint?style=for-the-badge\u0026url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyii2-extensions%2Finertia%2Fmain\" alt=\"Mutation Testing\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/yii2-extensions/inertia/actions/workflows/static.yml\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/yii2-extensions/inertia/static.yml?style=for-the-badge\u0026logo=github\u0026label=PHPStan\" alt=\"PHPStan\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cstrong\u003eInertia.js server-side integration layer for \u003ca href=\"https://github.com/yiisoft/yii2/tree/22.0\"\u003eYii2\u003c/a\u003e\u003c/strong\u003e\u003cbr\u003e\n    \u003cem\u003eServer-driven pages, shared props, redirects, and asset version handling without jQuery\u003c/em\u003e\n\u003c/p\u003e\n\n## Features\n\n\u003cpicture\u003e\n    \u003csource media=\"(max-width: 767px)\" srcset=\"./docs/svgs/features-mobile.svg\"\u003e\n    \u003cimg src=\"./docs/svgs/features.svg\" alt=\"Feature Overview\" style=\"width: 100%;\"\u003e\n\u003c/picture\u003e\n\n## Overview\n\n`yii2-extensions/inertia` is the server-side base package for building modern Inertia-driven pages on top of Yii2.\nIt does not ship a client adapter. Instead, it defines the server contract that future packages such as\n`yii2-extensions/inertia-vue`, `yii2-extensions/inertia-react`, and `yii2-extensions/inertia-svelte` can reuse.\n\n## Installation\n\n```bash\ncomposer require yii2-extensions/inertia:^0.1\n```\n\nRegister the bootstrap class in your application configuration:\n\n```php\nreturn [\n    'bootstrap' =\u003e [\\yii\\inertia\\Bootstrap::class],\n];\n```\n\n## Quick start\n\nRender a page directly from a controller action:\n\n```php\nuse yii\\inertia\\Inertia;\nuse yii\\web\\Controller;\nuse yii\\web\\Response;\n\nfinal class SiteController extends Controller\n{\n    public function actionIndex(): Response\n    {\n        return Inertia::render(\n            'Dashboard',\n            ['stats' =\u003e ['visits' =\u003e 42]],\n        );\n    }\n}\n```\n\nOr extend the convenience controller:\n\n```php\nuse yii\\inertia\\web\\Controller;\nuse yii\\web\\Response;\n\nfinal class SiteController extends Controller\n{\n    public function actionIndex(): Response\n    {\n        return $this-\u003einertia(\n            'Dashboard',\n            [\n                'stats' =\u003e ['visits' =\u003e 42],\n            ]\n        );\n    }\n}\n```\n\nOr inject the renderer contract. `Bootstrap` binds `ResponseRendererInterface` to `InertiaRenderer` in the DI container,\nso the action stays decoupled from the Inertia implementation and overlays (Inertia, JSON, API) can swap the renderer\nwithout rewriting controller code:\n\n```php\nuse yii\\inertia\\web\\ResponseRendererInterface;\nuse yii\\web\\{Controller, Response};\n\nfinal class SiteController extends Controller\n{\n    public function __construct(\n        $id,\n        $module,\n        private readonly ResponseRendererInterface $renderer,\n        $config = [],\n    ) {\n        parent::__construct($id, $module, $config);\n    }\n\n    public function actionIndex(): Response|string\n    {\n        return $this-\u003erenderer-\u003erender('Dashboard', ['stats' =\u003e ['visits' =\u003e 42]]);\n    }\n}\n```\n\n## Configuration example\n\n```php\nuse yii\\inertia\\Manager;\n\nreturn [\n    'bootstrap' =\u003e [\\yii\\inertia\\Bootstrap::class],\n    'components' =\u003e [\n        'inertia' =\u003e [\n            'class' =\u003e Manager::class,\n            'id' =\u003e 'app',\n            'rootView' =\u003e '@app/views/layouts/inertia.php',\n            'version' =\u003e static function (): string {\n                $path = dirname(__DIR__) . '/public/build/manifest.json';\n\n                return is_file($path) ? (string) filemtime($path) : '';\n            },\n            'shared' =\u003e ['app.name' =\u003e static fn(): string =\u003e Yii::$app-\u003ename],\n        ],\n    ],\n];\n```\n\n## Dev server support (Vite)\n\nThe bundled `\\yii\\inertia\\Vite` helper component renders asset tags for both development and production. When `devMode`\nis `true`, it emits `@vite/client` plus each configured entrypoint from `devServerUrl`, enabling Vite's HMR WebSocket\nend-to-end. When `devMode` is `false`, it reads the manifest at `manifestPath` and renders hashed asset tags for\nproduction.\n\nTypical development flow: run `npm run dev` to start the Vite dev server and launch Yii2 with a dev environment flag\n(for example, `YII_ENV=dev ./yii serve`). `YII_ENV` does not toggle `Vite::$devMode` on its own; your application\nconfiguration must wire the two together, for example:\n\n```php\n'components' =\u003e [\n    'inertiaVite' =\u003e [\n        'class' =\u003e \\yii\\inertia\\Vite::class,\n        'devMode' =\u003e YII_ENV === 'dev',\n        // ...\n    ],\n],\n```\n\nFor framework-specific setup, see:\n\n- [`yii2-extensions/inertia-react`](https://github.com/yii2-extensions/inertia-react) — React Refresh preamble auto-injection.\n- [`yii2-extensions/inertia-vue`](https://github.com/yii2-extensions/inertia-vue) — Vue HMR (no extra preamble).\n\n## Prop types (v3)\n\nThe package supports the Inertia v3 prop types for fine-grained control over when and how props are resolved:\n\n```php\nuse yii\\inertia\\Inertia;\n\nreturn Inertia::render(\n    'Dashboard',\n    [\n        'stats' =\u003e $stats,                                              // regular prop\n        'users' =\u003e Inertia::defer(fn () =\u003e User::find()-\u003eall()),        // loaded after render\n        'activity' =\u003e Inertia::optional(fn () =\u003e $user-\u003egetActivity()), // only on partial reload\n        'auth' =\u003e Inertia::always(fn () =\u003e ['user' =\u003e $identity]),      // always included\n        'items' =\u003e Inertia::merge($paginated)-\u003eappend('data', 'id'),    // merge instead of replace\n        'countries' =\u003e Inertia::once(fn () =\u003e Country::find()-\u003eall()),  // resolved once, cached\n    ],\n);\n```\n\nSee the [Usage Examples](docs/examples.md) for detailed documentation on each prop type.\n\n## Validation and flash messages\n\nThis package maps the session flash key `errors` to `props.errors` and exposes all remaining flashes at the top-level\n`flash` page key. A typical validation redirect looks like this:\n\n```php\nif (!$model-\u003evalidate()) {\n    Yii::$app-\u003esession-\u003esetFlash('errors', $model-\u003egetErrors());\n\n    return $this-\u003eredirect(['create']);\n}\n\nYii::$app-\u003esession-\u003esetFlash('success', 'Record created.');\n\nreturn $this-\u003eredirect(['view', 'id' =\u003e $model-\u003eid]);\n```\n\n## CSRF protection\n\nDrop in `yii\\inertia\\web\\Request` to enable Inertia's automatic cookie-to-header CSRF flow:\n\n```php\n'request' =\u003e [\n    'class' =\u003e \\yii\\inertia\\web\\Request::class,\n    'cookieValidationKey' =\u003e 'your-secret-key',\n],\n```\n\nInertia's HTTP client reads the `XSRF-TOKEN` cookie and sends it as `X-XSRF-TOKEN` automatically no client-side\nconfiguration required. See the [Configuration Reference](docs/configuration.md) for details.\n\n## Package boundaries\n\nThis repository intentionally does not include Vue, React, or Svelte bootstrapping. Those concerns belong in separate\nclient adapter packages built on top of the server contract defined here.\n\n## Documentation\n\nFor detailed configuration options and advanced usage.\n\n- 📚 [Installation Guide](docs/installation.md)\n- ⚙️ [Configuration Reference](docs/configuration.md)\n- 💡 [Usage Examples](docs/examples.md)\n- 🧪 [Testing Guide](docs/testing.md)\n\n## Package information\n\n[![PHP](https://img.shields.io/badge/%3E%3D8.3-777BB4.svg?style=for-the-badge\u0026logo=php\u0026logoColor=white)](https://www.php.net/releases/8.3/en.php)\n[![Yii 22.0.x](https://img.shields.io/badge/22.0.x-0073AA.svg?style=for-the-badge\u0026logo=yii\u0026logoColor=white)](https://github.com/yiisoft/yii2/tree/22.0)\n[![Latest Stable Version](https://img.shields.io/packagist/v/yii2-extensions/inertia.svg?style=for-the-badge\u0026logo=packagist\u0026logoColor=white\u0026label=Stable)](https://packagist.org/packages/yii2-extensions/inertia)\n[![Total Downloads](https://img.shields.io/packagist/dt/yii2-extensions/inertia.svg?style=for-the-badge\u0026logo=composer\u0026logoColor=white\u0026label=Downloads)](https://packagist.org/packages/yii2-extensions/inertia)\n\n## Quality code\n\n[![Codecov](https://img.shields.io/codecov/c/github/yii2-extensions/inertia.svg?style=for-the-badge\u0026logo=codecov\u0026logoColor=white\u0026label=Coverage)](https://codecov.io/github/yii2-extensions/inertia)\n[![PHPStan Level Max](https://img.shields.io/badge/PHPStan-Level%20Max-4F5D95.svg?style=for-the-badge\u0026logo=github\u0026logoColor=white)](https://github.com/yii2-extensions/inertia/actions/workflows/static.yml)\n[![Super-Linter](https://img.shields.io/github/actions/workflow/status/yii2-extensions/inertia/linter.yml?style=for-the-badge\u0026label=Super-Linter\u0026logo=github)](https://github.com/yii2-extensions/inertia/actions/workflows/linter.yml)\n[![StyleCI](https://img.shields.io/badge/StyleCI-Passed-44CC11.svg?style=for-the-badge\u0026logo=github\u0026logoColor=white)](https://github.styleci.io/repos/1196150046?branch=main)\n\n## License\n\n[![License](https://img.shields.io/badge/License-BSD--3--Clause-brightgreen.svg?style=for-the-badge\u0026logo=opensourceinitiative\u0026logoColor=white\u0026labelColor=555555)](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyii2-extensions%2Finertia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyii2-extensions%2Finertia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyii2-extensions%2Finertia/lists"}