Looking to hire Laravel developers? Try LaraJobs

laravel-electricsql maintained by matfire

Description
Utilities for ElectricSQL in Laravel
Last update
2026/08/09 12:20 (dev-main)
License
Downloads
0

Comments
comments powered by Disqus

Utilities for ElectricSQL in Laravel

Installation

You can install the package via Composer:

composer require matfire/laravel-electricsql

You may publish all of the package's resources at once:

php artisan vendor:publish --tag="laravel-electricsql"

Or, you may publish each resource individually:

Publishing the Configuration File

php artisan vendor:publish --tag="laravel-electricsql-config"

Usage

You can use laravel-electricsql in two ways:

Route Macro

laravel-electricsql exposes a Route macro Route::electric that handles all the logic for you (sending the request, getting the response, stripping the headers) in a single line.

You can use it like so:

Route::electric('/electric/todo', ['table' => 'todos']);

This will register a GET route to the specified url and pass the keyed array as extra parameters to the request.

toResponse

If you want more control and handle some extra logic or effects in your own controller, laravel-electricsql also exposes the toResponse method. Since it's available as a singleton, you can get it in your Controller parameters and use it like so:

use Matfire\LaravelElectricsql\LaravelElectricsql;

class TodoElectricController extends Controller
{
    /**
     * Handle the incoming request.
     */
    public function __invoke(Request $request, LaravelElectricsql $electric)
    {
        return $electric->toResponse($request, ["table" => "todos"]);
    }
}

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Thank you for considering contributing to Laravel Electricsql! Please review our contributing guide to get started.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

Laravel Electricsql is open-sourced software licensed under the MIT license.