PHPackages                             neoisrecursive/inertia-tempest - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. neoisrecursive/inertia-tempest

ActiveLibrary[Framework](/categories/framework)

neoisrecursive/inertia-tempest
==============================

A inertia adapter for the tempestphp framework

v1.0.0-beta.3(7mo ago)85.4k↓50%[5 issues](https://github.com/NeoIsRecursive/inertia-tempest/issues)[1 PRs](https://github.com/NeoIsRecursive/inertia-tempest/pulls)MITPHPPHP ^8.4CI passing

Since Jul 9Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/NeoIsRecursive/inertia-tempest)[ Packagist](https://packagist.org/packages/neoisrecursive/inertia-tempest)[ RSS](/packages/neoisrecursive-inertia-tempest/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (12)Used By (0)

Inertia tempest
===============

[](#inertia-tempest)

[![Coverage Status](https://camo.githubusercontent.com/ca085034b7016f4a617e88160d25608671484478a08cca3fe5c37167ca85870c/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f4e656f49735265637572736976652f696e65727469612d74656d706573742f62616467652e7376673f6272616e63683d6d61696e)](https://coveralls.io/github/NeoIsRecursive/inertia-tempest?branch=main)

installation
------------

[](#installation)

```
composer require neoisrecursive/inertia-tempest
```

Setup
-----

[](#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 `Back` response.
- 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

[](#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

[](#manual-setup)

If you don't want to use the installer, you can do the following steps manually:

#### Backend

[](#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:

```

```

#### Frontend

[](#frontend)

Install the bundler of your choice, since tempest comes with a vite installer, that is very much recommended. [Tempest vite docs](https://tempestphp.com/1.x/features/asset-bundling).

When that is done, you can go on to install your prefered inertia client by following the guide on inertia's official site [here](https://inertiajs.com/client-side-setup)

### Usage

[](#usage)

It is pretty similar to the laravel adapter, except that the `inertia` function is a namespaced function.

```
use Tempest\Http\Get;
use NeoIsRecursive\Inertia\InertiaResponse;
use NeoIsRecursive\Inertia\Inertia;

use function NeoIsRecursive\Inertia\inertia;

final class ReviewController
{
    // Using the inertia helper function
    #[Get(uri: '/reviews/{review}')]
    public function show(Review $review): InertiaResponse
    {
        return inertia('reviews/show', [
            'review' => $review,
        ]);
    }

    // Using dependency injection
    #[Get(uri: '/reviews')]
    public function show(Inertia $inertia): InertiaResponse
    {
        return $inertia->render('reviews/index', [
            'reviews' => Review::all(),
        ]);
    }
}
```

Configuration
-------------

[](#configuration)

This is the default config:

```
