johnnyfreeman/laravel-turbo

Hotwire Turbo integration for Laravel.

Maintainers

Package info

github.com/johnnyfreeman/laravel-turbo

pkg:composer/johnnyfreeman/laravel-turbo

Statistics

Installs: 3 652

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

0.2 2023-03-11 18:13 UTC

This package is auto-updated.

Last update: 2026-03-12 01:24:44 UTC


README

Some lightweight tools for sending Turbo Streams to the front end.

Installation

You can install the package via composer:

composer require johnnyfreeman/laravel-turbo

Usage

Controler

class PostCommentController
{
    public function store(Request $request, Post $post)
    {
        $comment = $post->comments()->create([
            'text' => $request->get('text')
        ]);

        if ($request->wantsTurboStream()) {
            return turbo_stream()
                ->prepend('comments', view('posts.comment', ['text' => $comment->text]))
                ->append('notifications', view('notifications.simple', ['title' => 'Post comment created!']));
        }

        return back();
    }
}

License

The MIT License (MIT). Please see License File for more information.