Search by

claviron / laravel

iadev09claviron

Claviron drivers and adapters for Laravel: cache, sessions, database, broadcasting, queue, schedule, and the Octane client

Package info

github.com/claviron/laravel

pkg:composer/claviron/laravel

Statistics

Installs: 11

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.5 2026-11-21 00:55 UTC

This package is auto-updated.

Last update: 2026-11-21 00:57:25 UTC


README

The claviron/laravel Composer package exposes Laravel adapters under Lumenize\. Claviron's native/static classes remain under Claviron\; driver names, native functions and event topics are unchanged. See the namespace migration notes before upgrading workers.

Source changes belong in the Lumenize repository. The standalone Composer repository is generated from committed package sources; Packagist versions follow its release tags. Composer installs PHP integration code, not the native Claviron host or the Lumenize executable. Lumenize owns the package export tooling and release configuration in this repository; Claviron releases its claviron/sapi dependency independently.

This package replaces Laravel's server-side Pusher HTTP call with Claviron's native broadcast primitive. Browser clients continue to use Laravel Echo and the Pusher WebSocket protocol.

// config/broadcasting.php
'default' => env('BROADCAST_CONNECTION', 'claviron'),

'connections' => [
    'claviron' => [
        'driver' => 'claviron',
        'key' => env('PUSHER_APP_KEY'),
        'secret' => env('PUSHER_APP_SECRET'),
    ],
],

The normal /broadcasting/auth route and routes/channels.php declarations remain authoritative for private and presence channels. No Pusher PHP SDK or HTTP publisher is used by this connection.

Fleet-global channel occupancy transitions are ordinary typed Laravel events:

use Lumenize\Broadcasting\Events\ChannelOccupied;
use Lumenize\Broadcasting\Events\ChannelVacated;
use Illuminate\Support\Facades\Event;

Event::listen(ChannelOccupied::class, function (ChannelOccupied $event): void {
    // $event->appId, $event->channel, $event->time (CarbonImmutable)
    // Presence channels also carry $event->userId and $event->userInfo.
});

Event::listen(ChannelVacated::class, function (ChannelVacated $event): void {
    // The last fleet subscriber has left this app's channel.
});

The package subscribes the persistent application loop to both bus topics. appId keeps applications separate even when they use the same channel name.

Native SQLite connections

Set 'claviron' => 'example' on a Laravel SQLite connection to use the host's named example pool. The host must enable sqlite and configure that pool; missing native support is an error, not a silent PDO fallback. Eloquent, query events, savepoints and transaction callbacks remain Laravel APIs. Ordinary Artisan commands continue using Laravel's PDO SQLite driver.

Lumenize console

The lumenize executable runs your application's own Artisan entry. It is installed separately from the Composer package. From your application directory:

lumenize list

It does not start an HTTP server. If you build the executable from source, its Rust package is lumenize-cli; see the CLI guide.

Run that executable from your Laravel application root, for example /path/to/lumenize list. It executes ./artisan in the native PHP engine; your autoloader, bootstrap, profiles and custom preparation remain owned by that local entry. No package runner replaces it, no HTTP server or TaskService starts, and the entry is not modified. Command arguments, terminal input/output and the command's exit status are preserved. If ./artisan is missing, the launcher reports that no Laravel application was found here and exits with failure. It does not require or automatically install a Composer package.

This entry does not yet attach to a live fleet or prepare native DB/cache services. Use ordinary PHP drivers for detached commands; explicit Claviron drivers need a host with those capabilities prepared. --live is not implemented.

The isolated external console check takes a Composer autoloader and the built binary: php tests/artisan.php /path/to/vendor/autoload.php /path/to/lumenize.

Console configuration

The auto-discovered Lumenize\Providers\LumenizeProvider supplies defaults only when Laravel is running in console mode. Applications disabling package discovery register that class in their own provider list.

Without an application config file, config('lumenize.config_path') returns lumenize.yaml. Optionally publish the defaults:

lumenize vendor:publish --tag=lumenize-config

Override them in your application's config/lumenize.php:

return [
    'config_path' => 'config/example.yaml',
];

The path is relative to the application's working directory. Application values and cached Laravel configuration remain authoritative. The provider declares configuration only; it does not yet read that YAML, prepare native services or attach to Orbit. Ordinary php artisan can also publish this configuration.

Application events

Think in directions relative to this PHP application:

Direction Application code Claviron's role
Local Dispatch and listen with Laravel's ordinary event API Nothing crosses the application boundary unless this class is explicitly relayed or is a FleetEvent.
Incoming Register a FleetEvent class with EventBridge::subscribe(), then use an ordinary Laravel listener Claviron receives topic and payload, decodes the registered class, and dispatches it locally. Subscribe before the work whose event matters; there is no replay.
Outgoing Dispatch a FleetEvent or call EventBridge::publish() Claviron publishes its stable topic and payload to the application event bus.

Claviron\Runtime\Event is the incoming native envelope. Laravel code normally handles the decoded event class, not the envelope or the Orbit link. A link presence subscriber is optional application behavior; Edge already logs transport reachability without any PHP subscription.

An ordinary Laravel event can also travel from one PHP worker to another. In that case, register its class with relay() before Laravel's listener chain is registered:

use Lumenize\EventBridge;
use App\Events\DemoEvent;

app(EventBridge::class)->relay([DemoEvent::class]);

Dispatch remains ordinary Laravel code. The bridge converts the event into the existing Claviron ApplicationEvent: the runtime (php), named application, Laravel class name, envelope ID, and serialized object travel in one fleet frame. Rust rejects another runtime or application before PHP sees the frame. One application worker claims the envelope and runs Laravel's ordinary listener chain; a ShouldQueue listener therefore enqueues one job for the application's queue pool. The envelope ID remains transport context and is not injected into the Laravel event.

Events shared with Rust, JavaScript, or Python use a stable topic and the FleetEvent contract. relay() is for serialized PHP classes and does not make that serialization a cross-language contract. Incoming delivery never publishes the same event back to the bus.

Cache

The claviron cache driver stores values in a cache store the host declares in its runtime cache configuration (cache.yaml). Each Laravel store chooses its runtime store with runtime_store:

// config/cache.php
'default' => env('CACHE_STORE', 'shared'),

'stores' => [
    'shared' => [
        'driver' => 'claviron',
        'runtime_store' => 'fleet',
    ],
    'remote' => [
        'driver' => 'claviron',
        'runtime_store' => 'redis',
    ],
    'runtime_default' => [
        'driver' => 'claviron',
    ],
],
  • Cache::store('remote') uses the runtime store named redis, whatever the runtime's default store is. The Laravel store's name is yours and selects nothing by itself, and a runtime store's name implies no backend: its driver in cache.yaml does. Orbit, Redis, memory and file stores are all selected the same way.
  • Leaving runtime_store out, or setting it to null, selects the runtime's default store. It is never guessed from the Laravel store's name or from an environment variable.
  • A name the runtime does not have throws Claviron\Runtime\CacheException when the store is first resolved. An empty string or a value that is not a string throws InvalidArgumentException. Neither falls back to the default store.
  • fallback names another Laravel store to use only where PHP runs without the runtime, such as a plain Artisan or test process. It never replaces a runtime store that is missing.

Values keep their PHP types: scalars and arrays are stored natively, so other runtime readers can use them, and objects are serialized. Expiry follows Laravel: a zero or negative lifetime forgets the key, and no lifetime keeps it until it is removed. flush() clears the whole runtime store, including keys under another prefix, so give each application its own runtime store.

increment(), decrement() and lock() do not use the runtime store. They use the host's fleet counters and locks, keyed with the Laravel store's prefix, whichever runtime store runtime_store selects. They do not follow a Redis runtime store into Redis, get() does not see a counter, and flush() does not reset counters or locks.

Tags

Cache::store($name)->supportsTags() is true when the selected runtime store supports tags, including when runtime_store is omitted and the runtime's default store is used. Today that is an Orbit store without an l2 backing store. On any other store, tags() throws Laravel's usual BadMethodCallException, and untagged reads and writes keep working.

Cache::tags(['people', 'artists'])->put('John', $john, 600);
Cache::tags(['people', 'authors'])->put('Anne', $anne, 600);

Cache::tags(['people', 'artists'])->get('John');

// Removes John and Anne: both lists contain `people`.
Cache::tags(['people'])->flush();

As in Laravel, a tagged item is read through the same ordered list of tags it was stored with, a flush removes what was stored under any list containing a flushed tag, and untagged keys are separate from tagged ones. A flush is one invalidation in the runtime store, seen by every worker; it walks no keys and stores no tag identifiers in the cache. A flushed tag takes new writes immediately.

Where it differs from Laravel's built-in stores:

  • Tag names must be strings and valid UTF-8, and a list must name at least one tag. Otherwise tags() throws TypeError, ValueError or InvalidArgumentException.
  • Tags are scoped by the Laravel store's prefix, as keys are. Two Laravel stores with the same runtime store and prefix share their tags.
  • increment() and decrement() on a tagged cache throw BadMethodCallException: counters keep no tags and would survive a flush.
  • A runtime store limits how many tags one entry or one flush carries; Orbit stores keep up to 16, fewer for a long key. More throws Claviron\Runtime\CacheTooManyTagsException, whose $count and $max say how many were given and kept, and nothing is written.
  • add() reads and then writes; it is not atomic, tagged or not.

As in Laravel, lock() on a tagged cache is the store's untagged lock, and clear() on a tagged cache clears the whole store; flush() is the tagged operation.

Sessions

The claviron session driver stores Laravel's serialized session payload in a Claviron cache store. Give sessions their own named cache store so application cache flushes cannot remove them:

// config/cache.php
'claviron_sessions' => [
    'driver' => 'claviron',
    'runtime_store' => 'sessions',
    'prefix' => 'my-app-session-',
],

// config/session.php
'driver' => env('SESSION_DRIVER', 'claviron'),
'store' => env('SESSION_STORE', 'claviron_sessions'),

The runtime store may compose Orbit L1 with Redis L2. Laravel's session blocking uses the same cache repository's Orbit lock implementation when session.block_store selects this store.

An explicit session.store is preserved. If it is absent, null or empty, the provider uses Laravel's configured cache.default; the driver name claviron does not require a cache store named claviron.

Bind data to an existing native session

For a route already protected by the host's native auth policy, opt in:

Route::middleware('native.session:api')->group(function () {
    Route::post('/example', function (Illuminate\Http\Request $request) {
        $request->session()->flash('notice', 'Saved');

        return response()->noContent();
    });
});

Register SessionServiceProvider and select session.driver=claviron. The alias is optional route middleware, not a global API/session boot hook. The required argument (api above) is a data namespace, not a guard selector; the host's vhost/route guard must already decide who this request belongs to. Different namespaces remain separate even for the same native session ID.

StartNativeSession uses the verified native session ID and remaining credential lifetime, honors session.store or the configured cache default, and emits no Laravel session cookie. Missing/expired native sessions are rejected. Applications can subclass allowsGuest() for transient login forms; guest data is never saved. Subclasses can retain their own native CSRF/audit integration without reimplementing the identity-to-cache binding. This does not introduce another login or auth session.

Flash retains ordinary Laravel aging and the configured Laravel serialization. The default PHP-serialized payload is not directly shared with Rust. Laravel's optional session.serialization=json can provide a readable representation, but coordinating Rust writes/flash consumption is a separate application concern.

Persistent Laravel benchmarks

Lumenize\Http\Controllers\BenchController provides opt-in plain, json, echo and state actions. Register them on stateless API routes when measuring Laravel; do not put session middleware in a minimal framework baseline. The controller requires the context produced by Lumenize\Octane\ClavironClient and rejects ordinary script requests. Response headers report the application mode, persistent boot ID, request count and process ID. Repeated requests with one boot ID and increasing counts verify that the application stays booted.

The application owns route registration.