Download the PHP package dancycodes/hyper without Composer
On this page you can find all versions of the php package dancycodes/hyper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dancycodes/hyper
More information about dancycodes/hyper
Files in dancycodes/hyper
Package hyper
Short Description Laravel-native reactive frontends using Datastar. Build dynamic UIs with Blade templates.
License MIT
Homepage https://laravel-hyper.com
Informations about the package hyper
Laravel Hyper
What is Laravel Hyper?
Laravel Hyper integrates Datastar—a reactive hypermedia framework—with Laravel's development patterns, enabling you to build reactive user interfaces using server-side rendering and Blade templates.
Datastar provides the reactive signals system and frontend reactivity engine. Laravel provides the backend framework and development patterns. Hyper bridges these two technologies with Laravel-specific helpers, Blade directives, CSRF protection, validation integration, and file upload handling.
📚 Full Documentation at laravel-hyper.com
The Problem Hyper Solves
Modern web applications benefit from reactive interfaces where UI updates feel instant—users expect immediate feedback when clicking buttons, typing in search fields, or submitting forms. Achieving this responsiveness traditionally required either building separate JavaScript frontends or accepting slower full-page reloads.
Hyper offers server-driven reactivity: your Laravel application maintains control of business logic, validation, and data access while the interface updates reactively. This approach works well when your application logic belongs on the server and you want reactive UI without managing complex client-side state.
Core Technologies
Datastar (Reactive Framework)
Datastar is an independent hypermedia framework that powers the reactive behavior in Hyper applications. It provides:
- Reactive Signals: Variables that automatically update UI when they change
- Data Attributes: HTML attributes like
data-bind,data-text,data-showfor reactive behavior - HTTP Actions: Trigger server requests with
@get,@postand other verbs - Server-Sent Events: Receive updates from the server via SSE
- DOM Morphing: Efficiently update HTML without full page reloads
All reactivity in Hyper applications comes from Datastar. When you use data-bind, data-text, or any reactive attribute, that's Datastar handling the reactivity.
Laravel (Backend Framework)
Laravel provides the server-side foundation—routing, controllers, Blade templates, validation, Eloquent, and all the patterns Laravel developers know.
Hyper (Integration Layer)
Hyper connects Datastar and Laravel with:
Server-Side Helpers:
hyper()- Fluent response builder for reactive responsessignals()- Read signals sent from the frontend (similar torequest())
Blade Directives:
@hyper- Include Datastar JavaScript and CSRF token@signals- Initialize signals from PHP data@fragment/@endfragment- Define reusable view sections
Laravel Integration:
@postx,@putx,@patchx,@deletex- HTTP actions with automatic CSRF tokensdata-error- Display Laravel validation errorsdata-navigate- Client-side navigation with Laravel routes- Validation integration via
signals()->validate() - Base64 file upload handling with
signals()->store()
Custom Attributes:
data-for- Optimized loops for rendering collectionsdata-if- Conditional rendering based on signals
Requirements
- PHP 8.2 or higher
- Laravel 11.0 or higher
Installation
Install Laravel Hyper via Composer:
Laravel's package auto-discovery will register the service provider automatically.
Publish the JavaScript assets to your public directory:
This copies Datastar and Hyper's JavaScript files to public/vendor/hyper/js/.
Add the @hyper directive to your layout's <head> section:
The @hyper directive includes the CSRF meta tag and loads the JavaScript module.
Quick Start
Reactive State with Signals
Signals are reactive variables. When a signal's value changes, any UI element displaying that signal updates automatically. This concept comes from Datastar.
The @signals directive (Hyper) creates signals from PHP data. The data-bind and data-text attributes (Datastar) make the interface reactive.
Server Communication
Use CSRF-protected HTTP actions to communicate with your Laravel controllers:
The @postx action (Hyper) automatically includes Laravel's CSRF token. The data-error attribute (Hyper) displays validation errors.
The signals() helper (Hyper) reads signals from the request. The hyper() helper (Hyper) builds the response.
📚 Learn more at laravel-hyper.com
Updating HTML Content
Render Blade views to update specific sections of your page:
Datastar receives the rendered HTML and updates the matching element by ID.
📚 Learn more at laravel-hyper.com
Working with Signals
Signal Types
Signals come in three types, each serving different purposes:
Regular Signals (sent to server with every request):
Local Signals (stay in browser, never sent to server):
Local signals are useful for UI state that doesn't need server processing—dropdowns, accordions, modal visibility, etc.
Locked Signals (protected from client tampering):
Locked signals are stored encrypted in the session and validated on every request. If a locked signal is tampered with, Hyper throws a HyperSignalTamperedException. This feature is provided by Hyper for secure state management.
📚 Learn more at laravel-hyper.com
Creating Signals
The @signals directive offers several syntaxes:
Array syntax:
Variable syntax:
Spread syntax:
Automatic type conversion:
The @signals directive automatically converts Laravel types:
Reading Signals
In the frontend (Datastar):
The $ prefix accesses signal values in Datastar expressions.
In the backend (Hyper):
Updating Signals
From the frontend (Datastar):
From the backend (Hyper):
Validation
Laravel's validation system integrates seamlessly with signals through Hyper's signals()->validate() method:
When validation fails, Hyper automatically:
- Creates an
errorssignal with Laravel's error messages - Sends it to the frontend
- The
data-errorattribute displays field-specific errors
Custom Validation Messages
All Laravel validation features work with signals:
📚 Learn more at laravel-hyper.com
File Uploads
File inputs bound with data-bind automatically encode files as base64 (Datastar behavior). Hyper provides validation rules and storage helpers for handling these base64-encoded files.
Base64 Validation Rules
Hyper provides specialized validation rules for base64-encoded files:
Available validation rules:
b64file- Validates any base64-encoded fileb64image- Validates base64-encoded image filesb64max:size- Maximum file size in kilobytesb64min:size- Minimum file size in kilobytesb64mimes:ext1,ext2- Allowed file extensionsb64dimensions:constraints- Image dimension validation
Dimension constraints:
Supports: min_width, max_width, min_height, max_height, width, height, ratio
Storing Files
📚 Learn more at laravel-hyper.com
Fragment Rendering
Fragments let you define reusable sections within Blade views and render them independently.
From your controller, render specific fragments:
Fragment Targeting
By default, fragments target elements by ID. You can specify custom selectors:
Merge modes (Datastar):
outer- Replace entire element (default)inner- Replace inner HTML onlyprepend- Add content at the beginningappend- Add content at the endbefore- Insert before elementafter- Insert after element
Navigation
Hyper provides client-side navigation features that work with Laravel routes.
Link Navigation
The data-navigate attribute (Hyper) enables client-side navigation without full page reloads.
Server-Side Navigation
Full Page Redirects
For full page reloads (not AJAX):
📚 Learn more at laravel-hyper.com
Advanced Features
Streaming
Send continuous updates to the client using Server-Sent Events:
Route Discovery
Automatically generate routes from controller methods using PHP attributes:
Enable in config/hyper.php:
Use attributes in controllers:
Conditional Logic
Use conditional methods to build responses dynamically:
JavaScript Execution
Execute JavaScript code from the server:
Datastar Attributes Reference
Hyper applications use Datastar's reactive attributes. Here are the most commonly used:
State Management
data-signals="{...}"- Create reactive signalsdata-computed:name="expression"- Create computed signaldata-effect="expression"- Run code when signals change
Display & Binding
data-text="$signal"- Display signal value as textdata-bind="signal"- Two-way bind input to signaldata-show="condition"- Show/hide elementdata-class:name="condition"- Toggle CSS classdata-attr:name="value"- Set attribute value
Events
data-on:click="expression"- Handle click eventsdata-on:input="expression"- Handle input eventsdata-on:submit="expression"- Handle form submitdata-on:[event]="expression"- Handle any DOM event
Event modifiers:
data-on:click__prevent- Prevent defaultdata-on:submit__prevent__stop- Prevent default and stop propagationdata-on:input__debounce.300ms- Debounce input
HTTP Actions
@get('/url')- GET request@post('/url')- POST request@put('/url')- PUT request@patch('/url')- PATCH request@delete('/url')- DELETE request
Hyper's CSRF-protected actions:
@postx('/url')- POST with CSRF token@putx('/url')- PUT with CSRF token@patchx('/url')- PATCH with CSRF token@deletex('/url')- DELETE with CSRF token
References
data-ref="myRef"- Create reference to elementdata-intersect="expression"- Run when element enters viewport
For complete Datastar documentation, visit data-star.dev.
📚 For Hyper-specific attributes and Laravel integration, visit laravel-hyper.com
Testing
Run the test suite:
Hyper includes tests covering:
- Signals and state management
- Validation integration
- File upload handling
- Fragment rendering
- Navigation
- Security (locked signals, CSRF)
- Response building
What Can You Build?
Hyper works well for server-driven applications with reactive UI requirements:
- CRUD Interfaces: Admin panels, data tables, content management
- Forms: Multi-step wizards, dynamic forms with live validation
- Live Features: Real-time dashboards, notifications, chat interfaces
- Interactive UIs: Search, filtering, sorting, pagination
- File Management: Upload interfaces with previews and progress
Hyper maintains Laravel's server-side architecture while providing reactive user experiences.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Development Setup
- Clone the repository
- Install dependencies:
composer install - Run tests:
composer test - Ensure all tests pass before submitting pull requests
Security
Security vulnerabilities should be reported privately. Please review SECURITY.md for responsible disclosure procedures.
Credits
Laravel Hyper is made possible by:
- Laravel - The PHP framework for web artisans
- Datastar - The reactive hypermedia framework
- DancyCodes - Hyper's integration layer and Laravel-specific features
- The Laravel and Datastar communities
License
Laravel Hyper is open-source software licensed under the MIT license.
Support
- Documentation: laravel-hyper.com
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: [email protected]
Made with ❤️ for the Laravel community
All versions of hyper with dependencies
illuminate/support Version ^11.0|^12.0
symfony/finder Version ^5.4.2|^6.0|^7.0