Skip to content

Core: Routes

Stream routes JSON, Route::streams, EntryController, parse and defer.

Streams can register Laravel routes from JSON and through the Route::streams() macro.

Stream JSON routes

{
    "routes": [
        {
            "handle": "view",
            "uri": "{uri}",
            "parse": true,
            "view": "{layout}"
        },
        {
            "uri": "blog/{id}",
            "view": "posts.show",
            "defer": true
        }
    ]
}
Option Purpose
parse Register one route per entry (bind {field} placeholders from entries)
defer Register routes on App::booted() instead of immediately
view Blade view name passed to EntryController
middleware, verb, csrf Standard Laravel route options

URI placeholders like {entry.slug} become criteria bindings (entry__slug internally).

Route::streams macro

Route::streams('posts/{id}', [
    'stream' => 'posts',
    'view' => 'posts.show',
]);

String routes without @ default to EntryController with a view parameter.

EntryController

Streams\Core\Http\Controller\EntryController resolves:

  • The target stream
  • The entry (by route id or criteria parameters)
  • The view or redirect from route config

Returns Response::view() or a redirect response.

URL helper

URL::streams('posts/{id}', ['id' => 'hello']);

Related