Hybridly
This is a singleton instance that contains convenience methods for common actions. Most response-oriented methods are shortcuts to namespaced functions.
view
Returns a Hybridly\View\Factory for the given component and optional properties.
- See responses for more details.
- For dialogs, use the
dialognamespaced function.
Usage
return $this->hybridly->view('users.show', [
'user' => UserData::from($user),
]);properties
Returns updated properties for the current view.
- See responses for more details.
Usage
return $this->hybridly->properties([
'user' => UserData::from($user),
]);createExternalRedirect
Generates a response that redirects to an external website or non-hybrid endpoint.
- See also:
to_external_url - See external redirects for details.
Usage
return $this->hybridly->createExternalRedirect('https://google.com');onDemand
Creates a property that is only evaluated when explicitly requested through a partial reload.
- See also:
on_demand - See partial-only properties for more details.
Usage
return $this->hybridly->view('users.show', [
'user' => UserData::from($user),
'posts' => $this->hybridly->onDemand(fn () => PostData::collection($user->posts)),
]);deferred
Creates a property that is not included in the initial load, but is automatically loaded in a subsequent partial reload.
See also:
deferredSee deferred properties for more details.
Usage
return $this->hybridly->view('users.show', [
'user' => UserData::from($user),
'stats' => $this->hybridly->deferred(
callback: fn () => UserStatsData::from($user),
group: 'sidebar',
),
]);isHybrid
- See also:
is_hybrid
Determines whether the current request is hybrid. Optionally, a Illuminate\Http\Request instance can be given instead of using the current request.
Usage
if ($this->hybridly->isHybrid()) {
// ...
}isPartial
- See also:
is_partial
Determines whether the current request is a partial reload. Optionally, a Illuminate\Http\Request instance can be given instead of using the current request.
Usage
if ($this->hybridly->isPartial()) {
// ...
}share
Shares properties globally across all Hybridly responses.
Usage
$this->hybridly->share('auth.user', fn () => Auth::user());
$this->hybridly->share([
'app.name' => config('app.name'),
]);flush
Clears all currently shared global properties.
Usage
$this->hybridly->flush();persist
Marks one or more property paths as persisted so they are always included, even in partial responses.
Usage
$this->hybridly->persist([
'auth',
'flash',
]);resolveVersionUsing
Sets a callback used to resolve the asset version for responses.
Usage
$this->hybridly->resolveVersionUsing(fn () => md5_file(public_path('build/manifest.json')));setUrlResolver
Defines how the URL is resolved for the next response.
Usage
use Illuminate\Http\Request;
$this->hybridly->setUrlResolver(
fn (Request $request) => $request->fullUrl(),
);getUrlResolver
Returns the currently configured URL resolver callback.
Usage
$resolver = $this->hybridly->getUrlResolver();renderExceptionsInDevelopment
Ensures Hybridly exception rendering is enabled in both production and local environments.
Usage
$this->hybridly->renderExceptionsInDevelopment();renderExceptionsUsing
Defines the response that should be rendered when a handled exception occurs.
Usage
use Illuminate\Http\Request;
use Throwable;
$this->hybridly->renderExceptionsUsing(
fn (Throwable $exception, Request $request) => $this->hybridly->view('errors.server-error', [
'message' => $exception->getMessage(),
]),
);handleSessionExpirationUsing
Defines the response that should be returned when a 419 session expiration occurs.
Usage
$this->hybridly->handleSessionExpirationUsing(
fn () => redirect()
->route('login')
->with('error', 'Your session expired. Please login again.'),
);