Skip to content

What Is This ​

CG Web Framework is an experimental framework built on Laravel. Its core is two subsystems:

  • renderBlade: asks the server for a Blade fragment and puts the whole thing on the page.
  • Linker: calls PHP methods from HTML attributes and gets back data plus "named actions".

Both share a client-side state store (state), so "replace a whole block of HTML" and "keep what the user was in the middle of" don't conflict.

This wiki is a usage guide. It starts from why and ends with you writing a complete module. The precise specifications still live in the repo's docs/ folder.

Two claims ​

1. Server-driven interactivity doesn't need to round-trip state ​

Livewire sends a full snapshot back and forth on every request and signs it. Linker instead keeps state on the server; the browser only holds an opaque uuid.

LivewireLinker
Where state livesRound-trips with every request (snapshot + HMAC)Only on the server; the browser holds a uuid
Exposed surfaceAll public methods and propertiesOnly methods marked #[Computable]
What comes backHTML diffData + named actions
Server telling the browser to act$this->js('any JS'), effectively evalA table of named actions, no eval; CSP needs no unsafe-eval

Failures are fixed to a handful of shapes (validation / policy / expired / conflict / service / fatal …), and the browser has exactly one handler for them.

2. DOM diffing is optional ​

No morphing, no diffing: the whole innerHTML is replaced. That is only safe because "what the user was in the middle of" never lived in the DOM to begin with.

User expands row 3 → clicks "Refresh list" → the whole block of HTML is replaced → the row… is still expanded

It's still expanded not because a diff preserved it, but because it was never in the DOM. The open value lives in an in-memory key-value store, and new nodes read it back the moment they're bound.

Subsystems at a glance ​

SubsystemSingle responsibilityDoes not
renderBladeHTML transportDecide business logic
stateClient memory + declarative rendering (data-state-*)Send requests
LinkerBusiness round-trips: call in, data + named actions outReturn HTML or touch the DOM
FileDropChunked uploadsHandle business logic
modalDialogs and drawersFetch data
ComponentDeclarative UI compositionReinvent transport

None of the three core modules attach anything to window. The only entry point on a page is HTML attributes, and those must pass the @renderObject allow list first. What a block of DOM is allowed to do is written in the template, visible at a glance.

Thirty seconds ​

Server:

php
class CustomerLinker extends LinkerComponent
{
    public static string $alias = 'customer';

    #[Computable]                                        // callable from the browser (otherwise it doesn't exist)
    #[Validate(['keyword' => 'nullable|string|max:64'])]  // argument rules
    public function search(array $args): LinkerResponse
    {
        $this->set('keyword', $args['keyword'] ?? '');    // state stays on the server

        return $this->ok(['matchCount' => $this->query()->count()])
            ->call('render.fragment', [                   // tell the browser to act (named action)
                'target' => '#customer-list-results',
                'name' => CustomerController::class,
                'params' => ['mode' => 'results'],
            ]);
    }
}

Template:

blade
<div @linker('customer') @renderObject('customerPanel', ['render', 'state:read', 'state:write'])>
    <input type="search" data-linker-call="search" data-linker-on="input"
           data-linker-debounce="400" data-linker-args="keyword" data-state-bind="keyword">

    <p><span data-state-text="matchCount">0</span> matches</p>

    <div id="customer-list-results">@include('partials.customer.results')</div>
</div>

No new route, no controller, no resource, no front-end code.

For what it deliberately doesn't do, see Known Trade-offs.

Next: Quick Start.