Download the PHP package mojahed/spa without Composer
On this page you can find all versions of the php package mojahed/spa. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package spa
mojahed/spa
A Laravel SPA package powered by Alpine.js, Axios, and Bootstrap — no build step, no npm, no Vite. Load blade fragments dynamically, manage modals, offcanvases, and independent page sections with clean declarative components.
Requirements
- PHP >= 7.4
- Laravel >= 7.x (components & directives)
- Laravel >= 9.36 (for the
SpaRequest::fragmentIf()controller helper) - Bootstrap 5
- Alpine.js 3.x
- Axios
- SweetAlert2 (for confirm dialogs and toasts)
Installation
Publish and copy assets to your public directory:
Optionally publish config and views for customization:
Layout Setup
Add directives to your main layout file:
Use a custom Alpine component name:
Then define it in your scripts:
Directives
| Directive | Output |
|---|---|
@spacss |
CSS link tags (Bootstrap + spa.css) |
@spajs |
JS script tags (Alpine, Axios, Bootstrap, SweetAlert2, spa.js) + CSRF headers |
@spadata |
x-data="spa()" on body |
@spadata('name') |
x-data="name()" on body |
Components
<x-spa-target> — Inline Fragment Zone
Loads a blade fragment into an inline div. Optionally auto-loads on page ready.
Props
| Prop | Default | Description |
|---|---|---|
id |
required | Unique ID |
url |
'' |
URL to fetch |
auto-load |
false |
Load on page ready |
loader-type |
config default | spinner | skeleton | table | card |
loader-rows |
5 |
Skeleton/table rows |
loader-cols |
4 |
Table columns |
method |
get |
HTTP method |
params |
[] |
Query params array |
<x-spa-modal> — Bootstrap Modal Container
Props
| Prop | Default | Description |
|---|---|---|
id |
required | Unique ID |
size |
lg |
sm | md | lg | xl | fullscreen |
title |
'' |
Modal title |
loader-type |
config default | Loader type while loading |
static-backdrop |
true |
Prevent close on outside click |
scrollable |
false |
Scrollable modal body |
<x-spa-offcanvas> — Bootstrap Offcanvas Container
Props
| Prop | Default | Description |
|---|---|---|
id |
required | Unique ID |
title |
'' |
Header title |
placement |
end |
start | end | top | bottom |
width |
450px |
Width (end/start only) |
loader-type |
config default | Loader type while loading |
<x-spa-btn> — Button Trigger
Props
| Prop | Default | Description |
|---|---|---|
url |
'' |
Target URL |
method |
get |
HTTP method |
target |
'' |
Load into #spa-target id |
modal |
'' |
Load into modal id |
offcanvas |
'' |
Load into offcanvas id |
confirm |
false |
Show confirm dialog first |
confirm-title |
config | Confirm dialog title |
confirm-text |
config | Confirm dialog body text |
confirm-type |
warning |
SweetAlert icon type |
confirm-ok |
config | Confirm button label |
confirm-cancel |
config | Cancel button label |
on-success-reload |
'' |
Reload target by #id |
on-success-close |
'' |
Close modal/offcanvas by #id |
on-success-toast |
'' |
Show success toast message |
on-success-redirect |
'' |
Redirect to URL |
on-success-emit |
'' |
Dispatch custom Alpine event |
<x-spa-link> — Anchor Trigger
Same props as <x-spa-btn>, renders as an <a> tag.
<x-spa-form> — Axios Form Submit
Handles form submission with error binding and submitting state. Pass initial
field values through :data and bind inputs with x-model="{model}.{field}".
Props
| Prop | Default | Description |
|---|---|---|
url |
required | Submit URL |
method |
post |
HTTP method |
model |
form |
Name of the Alpine data object holding the fields |
:data |
[] |
Initial field values, e.g. :data="['name' => $item->name]" |
<x-spa-loader> — Standalone Loader
Dashboard — Independent Sections
Each section loads independently with its own loader, just like the AWS dashboard:
Controller — Fragment Detection
Use Laravel's built-in fragment system with the X-SPA-Request header automatically sent by the package:
Or directly with Laravel's fragmentIf:
JS Utilities
All utilities are globally available:
Configuration
Publish and edit config/spa.php:
Legacy Compatibility
If you are migrating from existing code that uses toast(), setParam(), getParam(), runScriptCode() — these are aliased to the new spa* functions so your existing code continues to work without changes.
License
MIT — Md. Mojahedul Islam
All versions of spa with dependencies
illuminate/support Version ^7.0|^8.0|^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/view Version ^7.0|^8.0|^9.0|^10.0|^11.0|^12.0|^13.0