Functions
Hybridly exposes a few global and namespaced utility functions.
Namespaced functions
The functions live in the \Hybridly
namespace and need to be imported before being used.
view
Renders a view with the given component and optional properties. The properties can be an array, an Arrayable
or a data object.
See also: responses
use function Hybridly\view;
return view('user.show', $user);
properties
Returns updated properties for an existing view.
See also: properties-only responses
use function Hybridly\properties;
return properties([
'user' => $user,
]);
dialog
Returns a dialog with the given properties and base view.
See also: dialogs
use function Hybridly\dialog;
return dialog(
component: 'users.dit',
properties: ['user' => $user],
base: route('users.show', $user),
);
partial
Creates a partial-only property.
See also: partial properties
use function Hybridly\view;
use function Hybridly\partial;
return view('user.show', [
'user' => $user,
'posts' => partial(fn () => Post::forUser($user)->paginate()),
]);
deferred
Creates a partial property that will automatically be loaded in a subsequent partial reload when the page loads.
See also: deferred properties
use function Hybridly\view;
use function Hybridly\deferred;
return view('user.show', [
'user' => $user,
'posts' => deferred(fn () => Post::forUser($user)->paginate()),
]);
to_external_url
Redirects to a non-hybrid view or an external domain.
See also: external redirects.
use function Hybridly\to_external_url;
return to_external_url('https://google.com');
is_hybrid
Determines whether the current request is hybrid. Optionally, a Illuminate\Http\Request
instance can be given instead of using the current request.
use function Hybridly\is_hybrid;
if (is_hybrid()) {
// ...
}
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.
use function Hybridly\is_partial;
if (is_partial()) {
// ...
}
Global functions
These functions are available globally when hybridly/laravel
is installed.
hybridly
When called without a parameter, this functions returns the Hybridly\Hybridly
singleton instance.
Otherwise, it is an alias of hybridly()->view()
.
Namespaced testing functions
partial_headers
Generates headers for testing partial requests. The first parameter is the view component name, and the second and third parameters are an array of only
and except
properties, respectively.
See also: partial reloads
use function Hybridly\Testing\partial_headers;
get('/', partial_headers('users.show', only: ['posts']))
->assertMissingHybridProperty('user')
->assertHybridProperty('posts');