PHPackages                             jati/ashravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. jati/ashravel

ActiveLibrary

jati/ashravel
=============

Zero-JS Single Page Application (SPA) functionality for Laravel Blade.

v1.0.1(2d ago)00MITJavaScriptPHP ^8.0

Since Jul 26Pushed todayCompare

[ Source](https://github.com/ginganomercy/ashravel)[ Packagist](https://packagist.org/packages/jati/ashravel)[ RSS](/packages/jati-ashravel/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (2)Versions (3)Used By (0)

⚡ Ashravel: TurboBlade
======================

[](#-ashravel-turboblade)

**TurboBlade** is an ultra-lightweight, zero-JS package for Laravel that turns your classic Server-Side Rendered (Blade) application into a blazingly fast Single Page Application (SPA).

Stop writing Webpack configs. Stop fighting React/Vue reactivity. Stop worrying about Livewire network bloat. Just write plain PHP/HTML, and let TurboBlade handle the magic.

---

🛡️ Security Analysis (Scraping &amp; Injection)
-----------------------------------------------

[](#️-security-analysis-scraping--injection)

Before deploying TurboBlade, it's essential to understand its security posture:

### 1. Cross-Site Scripting (XSS) Injection

[](#1-cross-site-scripting-xss-injection)

**Are you safe? YES, provided you follow Laravel standards.**TurboBlade updates your page using `document.body.innerHTML` and explicitly re-evaluates `` tags found in the new HTML.

- **The Rule:** You **MUST** use Laravel's default `{{ $variable }}` syntax to output user-generated content. This automatically escapes HTML entities.
- **The Danger:** If you use the raw syntax `{!! $variable !!}` to output user input, an attacker can inject malicious `` tags. TurboBlade will execute them upon page morph. Treat your Blade templates with the exact same XSS precautions as a standard Laravel app.

### 2. Web Scraping &amp; SEO (Search Engine Optimization)

[](#2-web-scraping--seo-search-engine-optimization)

**Is it safe from scrapers? NO. Is it good for SEO? YES.**TurboBlade is built on the *HTML-over-the-wire* philosophy. Your Laravel backend still returns **fully rendered HTML** on every request.

- **Scrapers:** Malicious bots and scrapers do not execute JavaScript. They just read the HTTP response. Because TurboBlade uses standard HTML routing, scrapers can read your content easily. To protect against malicious scraping, you must use server-side rate limiting (`ThrottleRequests` middleware) or a WAF like Cloudflare.
- **SEO:** This architecture is the "Holy Grail" for SEO. Googlebot will see your website as a traditional, fully-rendered HTML site, giving you a perfect 100/100 Lighthouse SEO score, while real humans experience the site as a lightning-fast SPA.

---

🖥️ Server Requirements &amp; Compatibility
------------------------------------------

[](#️-server-requirements--compatibility)

Ashravel is designed to be highly compatible with both modern and legacy enterprise applications. Because the core magic happens in Vanilla JavaScript, the PHP footprint is extremely minimal.

**Supported Versions:**

- **PHP:** `8.0`, `8.1`, `8.2`, `8.3`
- **Laravel:** `9.x`, `10.x`, `11.x`

*(Note: We intentionally drop support for PHP 7.x and Laravel 8 to encourage modern security standards, even though the code technically could run on them).*

---

📦 Installation
--------------

[](#-installation)

Install the package via Composer (we recommend pinning to a major version):

```
composer require jati/ashravel:"^1.0"
```

Publish the JavaScript assets to your public directory:

```
php artisan vendor:publish --tag="turboblade-assets"
```

---

🚀 How to Use (Usage Guide)
--------------------------

[](#-how-to-use-usage-guide)

### 1. Global Setup

[](#1-global-setup)

Open your main layout file (usually `resources/views/layouts/app.blade.php`), and place the Blade directive just before the closing `` or `` tag:

```

    My Awesome Laravel App

    @turbobladeScripts

        Home
        About Us

        @yield('content')

```

### 2. The Magic

[](#2-the-magic)

**You don't need to do anything else!**The moment you add `@turbobladeScripts`, all `` links and `` submissions across your entire application will automatically be intercepted. The browser will no longer do a full hard reload. Instead, TurboBlade fetches the next page in the background, merges the `` (to update CSRF tokens and CSS), and morphs the `` instantly.

### 3. Ignoring Specific Links/Forms

[](#3-ignoring-specific-linksforms)

If you have a link that you **do not** want TurboBlade to intercept (for example, a file download, a payment gateway redirect, or a heavy PDF generation), simply add the `data-turbo-ignore` attribute to the HTML element:

```

Download PDF

    @csrf
    Pay Now

```

### 4. Integration with Third-Party JS (Alpine.js, Google Maps, etc.)

[](#4-integration-with-third-party-js-alpinejs-google-maps-etc)

Because TurboBlade swaps the DOM, third-party JavaScript libraries might lose their state or event listeners. TurboBlade dispatches a custom event `turboblade:load` every time a page navigation finishes.

You can listen to this event to re-initialize your plugins:

```
document.addEventListener('turboblade:load', function(event) {
    console.log("New page loaded at: " + event.detail.url);

    // Example: Re-initialize Alpine.js components
    if (typeof Alpine !== 'undefined') {
        Alpine.initTree(document.body);
    }
});
```

---

⚠️ SPA Architectural Gotchas (Must Read)
----------------------------------------

[](#️-spa-architectural-gotchas-must-read)

Because TurboBlade transforms your traditional app into a Single Page Application, the browser never actually performs a hard refresh. Please be aware of these two common SPA pitfalls:

### 1. Memory Leaks (Global Event Listeners)

[](#1-memory-leaks-global-event-listeners)

If you attach an event listener to `window` or `document` inside a specific page (e.g., `welcome.blade.php`), it will not be destroyed when the user navigates away. If the user visits that page 10 times, the listener will be attached 10 times, causing a memory leak. **Solution:** Always bind page-specific listeners to local DOM elements (which get destroyed by TurboBlade during navigation), OR explicitly remove global listeners, OR initialize them once in your main layout.

### 2. External Scripts in the Body

[](#2-external-scripts-in-the-body)

TurboBlade safely re-evaluates *inline* scripts (e.g., `alert('hi')`) when navigating. However, it will **ignore** external scripts (e.g., ``) if they are placed inside the ``. **Solution:** Always place external `` tags inside the `` of your layout. TurboBlade's smart asset merger will detect and load them perfectly.

---

🛡️ Server-Side HTTP Middleware &amp; Redirect Support
-----------------------------------------------------

[](#️-server-side-http-middleware--redirect-support)

To handle SPA HTTP 301/302 Redirects and force hard browser reloads from your controllers, register the optional **`TurboBladeMiddleware`**:

### 1. Registering the Middleware

[](#1-registering-the-middleware)

In `bootstrap/app.php` (Laravel 11+) or `app/Http/Kernel.php` (Laravel 10 and below):

```
->withMiddleware(function (Middleware $middleware) {
    $middleware->web(append: [
        \Ashravel\TurboBlade\Middleware\TurboBladeMiddleware::class,
    ]);
})
```

- **SPA Redirect Support:** When a frontend SPA request (`X-TurboBlade: true`) encounters a backend redirect, the middleware attaches an `X-TurboBlade-Location` header so JavaScript can accurately update `history.pushState`.

### 2. Forcing a Hard Browser Reload

[](#2-forcing-a-hard-browser-reload)

When you need to force a full hard page reload (e.g., after login, logout, or session reset), use the static helper in your Controller:

```
use Ashravel\TurboBlade\Middleware\TurboBladeMiddleware;

public function logout(Request $request)
{
    Auth::logout();
    $response = redirect('/login');

    return TurboBladeMiddleware::forceReload($response);
}
```

---

🧪 Testing &amp; Verification
----------------------------

[](#-testing--verification)

Ashravel includes an automated test suite using **PHPUnit 10** and **Orchestra Testbench 9**.

To run the verification suite locally:

```
# 1. Install development dependencies
composer install

# 2. Run the test suite
composer test
# or
vendor/bin/phpunit
```

The test suite validates:

- **Blade Directive:** Compilation and rendering of `@turbobladeScripts`.
- **Asset Publishing:** Execution of `artisan vendor:publish --tag="turboblade-assets"`.
- **HTTP Middleware:** SPA redirect location headers (`X-TurboBlade-Location`) and reload instructions (`X-TurboBlade-Reload`).

---

👨‍💻 Author
----------

[](#‍-author)

**Rafly A.R**📧 Email: 📸 Instagram: [@galaxy\_scream](https://instagram.com/galaxy_scream)

---

🧠 Core Features Summary
-----------------------

[](#-core-features-summary)

- **Zero-Config:** 1 line of code to turn your app into an SPA.
- **CSRF Safe:** Automatically updates Laravel's `@csrf` tokens in the background on every navigation.
- **Scroll Memory:** Remembers your exact scroll position when you press the browser's "Back" button.
- **Asset Merging:** Automatically downloads new `` CSS files if the new page requires them.
- **Redirect &amp; Reload Aware:** Full server-side middleware support for HTTP 302 redirects and forced reloads.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

2d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a8c8add9718b841e43b15c555815dd6180eb37052bb3af1c88d5d9057ff7ce2c?d=identicon)[ginganomercy](/maintainers/ginganomercy)

---

Top Contributors

[![ginganomercy](https://avatars.githubusercontent.com/u/155315911?v=4)](https://github.com/ginganomercy "ginganomercy (11 commits)")

### Embed Badge

![Health badge](/badges/jati-ashravel/health.svg)

```
[![Health](https://phpackages.com/badges/jati-ashravel/health.svg)](https://phpackages.com/packages/jati-ashravel)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M348](/packages/psalm-plugin-laravel)[moonshine/moonshine

Laravel administration panel

1.3k253.1k86](/packages/moonshine-moonshine)[tallstackui/tallstackui

TallStackUI is a powerful suite of Blade components that elevate your workflow of Livewire applications.

728176.2k14](/packages/tallstackui-tallstackui)[illuminate/console

The Illuminate Console package.

13046.0M6.9k](/packages/illuminate-console)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)[hasinhayder/tyro-dashboard

Tyro Dashboard - Beautiful admin dashboard for managing Tyro roles, privileges, users, and settings

5443.8k](/packages/hasinhayder-tyro-dashboard)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
