urgorri / laravel-class-obf v1.0.0

Laravel Class Obfuscator

Production-grade CSS & HTML class masking for Laravel applications. Deterministically hashes CSS selector names and Blade class attributes using HMAC-SHA256 Base62 tokens. Zero runtime database or cache overhead.

⚡ Zero Overhead

Class mappings are pre-compiled at build time via Node AST scanner (php artisan classobf:build).

🔑 Deterministic Hash

Same secret key = identical obfuscated tokens across builds and microservices.

🛡️ Whitelist Support

Preserve dynamic JavaScript classes via glob patterns (data-*, is-*).

Live Obfuscation Engine

Source Input
Compiled Output
Total Classes

Obfuscated / Whitelisted

/

Payload Size Reduction

%

Live UI Render Preview

Below is a live component rendered in the DOM using the exact CSS compiled above. Toggle Production mode to watch the DOM class names change while the visual styling stays 100% identical.

Injected Stylesheet ():

Quickstart Integration

1. Install package via Composer composer require urgorri/laravel-class-obf
2. Publish config file php artisan vendor:publish --tag=classobf-config
3. Run obfuscation build step php artisan classobf:build

API & Directive Reference

Directive / Helper Example Usage Description
@cls('...') <div class="@cls('btn primary')"> Obfuscates inline space-separated class tokens in production.
@classObf([...]) <div class="@classObf(['card' => true])"> Evaluates conditional class arrays while substituting mapped tokens.
cls('...') cls('card shadow-sm') PHP helper function for string obfuscation.
asset_obf('...') <link rel="stylesheet" href="{{ asset_obf('css/app.css') }}"> Resolves obfuscated asset path from public/build-obf.