VEditor for Laravel
A package with a Blade directive, routes for the editor files and the AI endpoint, and a service that sanitizes content before saving.
- Tested: 12
- Compatible code: 11–13
- PHP 8.2+
Installation in 3 steps
-
Install the package
From the VEditor Composer repository; your licence key is the access key. The service provider registers itself.
terminalcomposer require veditor/laravel php artisan vendor:publish --tag=veditor-config # config/veditor.php, .env: VEDITOR_LICENSE_KEY -
Add the editor to a form
The
@veditordirective renders the field, the styles and the script with the options fromconfig/veditor.php.resources/views/articles/edit.blade.php<form method="post"> @csrf @veditor('content', old('content', $article->body), ['height' => '400px']) <button>Save</button> </form> -
Sanitize on save
VEditorService::sanitize()uses the same styles as the editor, so valid content passes unchanged.app/Http/Controllers/ArticleController.phppublic function update(Request $request, Article $article, VEditorService $veditor) { $this->authorize('update', $article); $article->body = $veditor->sanitize($request->input('content')); $article->save(); }
What you get
Integration features for Laravel, where you would expect them.
- Blade directiveA directive rather than a component, so article content never goes through the Blade compiler.
- Editor files from the package
GET /veditor/assets/{version}/{file}, only.jsand.css, cached for a year. - AI endpoint
POST /veditor/aibehindwebandauthmiddleware, with the session’s CSRF token andStreamedResponse. - Roles and limits
aiFeaturesUsing()per user andbeforeAiRequestUsing(), for example withRateLimiter. - Configuration in one fileLicence, styles, editor options, file manager, upload and AI keys from
.env. - CSP nonceTaken from
Vite::cspNonce()automatically.
Try it in your browser
The demo has the full toolbar and shows what the PHP sanitizer returns for your content.
All integrations
-
Laravel
Composer package Tested: 12 Compatible code: 11–13 -
Symfony
Symfony bundle Tested: 7.4 LTS Compatible code: 6.4–8 -
Yii2
Code to copy Tested: 2.0.55 -
PHP
Without a framework PHP 8.1+ -
React
npm package Tested: 18 Compatible code: 17+ -
Vue 3
npm package Tested: 3.5 Compatible code: 3.2+ -
Your file manager
Editor hooks
Names and trademarks belong to their owners. Their use does not imply partnership.