microweber-packages / microweber-template-custom-css
Standalone Laravel package for template CSS management: live-edit CSS, user custom CSS, multi-file registry, CSS validation, URL rewriting, and Filament admin. Reusable in any Laravel app.
Package info
github.com/microweber-packages/microweber-template-custom-css
pkg:composer/microweber-packages/microweber-template-custom-css
v1.0.0
2026-11-03 14:28 UTC
Requires
- php: ^8.1
- illuminate/database: ^10.0|^11.0|^12.0|^13.0
- illuminate/filesystem: ^10.0|^11.0|^12.0|^13.0
- illuminate/http: ^10.0|^11.0|^12.0|^13.0
- illuminate/routing: ^10.0|^11.0|^12.0|^13.0
- illuminate/support: ^10.0|^11.0|^12.0|^13.0
- microweber-packages/microweber-package: *
- microweber-packages/microweber-url: *
- sabberworm/php-css-parser: ^8.4|^9.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- filament/filament: ~5.0
- larastan/larastan: ^3.9
- laravel/dusk: ^8.0|^9.0
- livewire/livewire: ^3.0|^4.0
- orchestra/testbench: ^8.0|^9.0|^10.0
- phpunit/phpunit: ^10.0|^11.0
Suggests
- filament/filament: Required for the Filament admin CSS editor
Provides
None
Conflicts
None
Replaces
- microweber-packages/template-custom-css: *
This package is auto-updated.
Last update: 2026-11-03 17:07:41 UTC
README
Standalone Laravel package for template CSS management:
- Live-edit CSS (
live_edit.cssper template) - User custom CSS (option-stored
custom_css) - Arbitrary multi-file registry (register per-page or custom slots)
- CSS validation via sabberworm/php-css-parser
- URL rewriting for portable backups (
userfiles_url→../../) - Multisite filenames (
live_edit_{environment}.css) - Filament admin page for editing CSS
- Routes compatible with Microweber live-edit frontend JS
Installation
composer require microweber-packages/microweber-template-custom-css
Publish config (optional):
php artisan vendor:publish --tag=template-custom-css-config
File locations (CMS-compatible)
| Slot | Path |
|---|---|
| Live edit | {css_base_path}/{template}/live_edit.css |
| Multisite live edit | {css_base_path}/{template}/live_edit_{env}.css |
| Custom CSS cache | {css_cache_path}/custom_css.{crc32(site)}.{version}.css |
In Microweber CMS these resolve to:
userfiles/css/{template}/live_edit.cssuserfiles/cache/custom_css.*.css
Do not change these paths — template backup/restore depends on them.
Usage (standalone Laravel)
use MicroweberPackages\TemplateCustomCss\Facades\TemplateCustomCss; // Save live-edit CSS for a template TemplateCustomCss::liveEdit()->saveLiveEditCssContent('.hero { color: red; }', 'my-theme'); // User custom CSS TemplateCustomCss::customCss()->saveCustomCss('body { font-size: 16px; }'); // Validate $result = TemplateCustomCss::validate('a { color: #fff; }'); // ['valid' => true, 'errors' => []] // Register a future per-page file TemplateCustomCss::registerFileType(new \MicroweberPackages\TemplateCustomCss\Services\RegisteredCssFileHandler( 'page_42', ['filename' => 'page_42.css', 'storage' => 'file', 'validate' => true, 'rewrite_urls' => true], config('template-custom-css'), app(\MicroweberPackages\TemplateCustomCss\Contracts\OptionStoreInterface::class), app(\MicroweberPackages\TemplateCustomCss\Services\CssValidator::class), app(\MicroweberPackages\TemplateCustomCss\Services\CssUrlRewriter::class), ));
Routes
| Method | Path | Name |
|---|---|---|
| POST | /api/current_template_save_custom_css |
current_template_save_custom_css |
| POST | /api/layouts/template_remove_custom_css |
template_remove_custom_css |
| ANY | /api/template/print_custom_css |
print_custom_css |
| POST | /api/template/save_custom_css |
api.template.save_custom_css |
| POST | /api/template/validate_css |
api.template.validate_css |
| GET | /api/template/live_edit_css_url |
api.template.live_edit_css_url |
Tests
# From monorepo root php artisan test packages/microweber-template-custom-css # PHPStan (level 9) composer analyse -- packages/microweber-template-custom-css/src # or ./vendor/bin/phpstan analyse -c packages/microweber-template-custom-css/phpstan.neon.dist
License
MIT