Search by

crystoline / xpsr-view-blade

crystoline

Blade views for XPSR applications, standalone through illuminate/view, in place of Twig

Package info

github.com/crystoline/xpsr-view-blade

Homepage

pkg:composer/crystoline/xpsr-view-blade

Statistics

Installs: 3

Dependents: 0

Suggesters: 1

Stars: 0

Open Issues: 0

v0.5.0 2026-10-30 11:06 UTC

This package is auto-updated.

Last update: 2026-10-30 11:16:42 UTC


README

Blade views for XPSR applications, without the rest of Laravel: illuminate/view in place of Twig.

composer require crystoline/xpsr-view-blade
// config/app.php
'view_engine' => env('VIEW_ENGINE', 'blade'),
'view_cache_dir' => dirname(__DIR__) . '/var/cache/views',

views/home/index.blade.php is the view home.index:

@extends('layouts.main')

@section('content')
    <h1>Hello, {{ $user->name }}</h1>
    @if ($xpsr->can('update', $task))
        <form method="post" action="/tasks/{{ $task->id }}">
            @csrf
            <input name="title">
        </form>
    @endif
@endsection

The template functions are methods of $xpsr, which every view has: {{ $xpsr->session('status') }}, $xpsr->auth_user(). @csrf prints csrf_field(). {{ }} escapes values, and prints the HTML of functions such as csrf_field() as it is.

Layouts, sections, stacks, @include, and the control structures work. Components (<x-...>) and directives that call Laravel's own helpers, such as @method, need parts of a Laravel application and are not supported.

Compiled templates go to app.view_cache_dir, or without one to a directory under the system temporary directory. A template is compiled again when its file is newer than the compiled copy, so run php xpsr view:clear after a deploy that keeps the files' original times. BladeViewHandler::compiler() returns the Blade compiler, for custom directives, and factory() the view factory, for shared data.

Requires PHP 8.4+.