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+
Article form in Laravel with VEditor rendered by the @veditor directive

Installation in 3 steps

  1. Install the package

    From the VEditor Composer repository; your licence key is the access key. The service provider registers itself.

    terminal
    composer require veditor/laravel
    php artisan vendor:publish --tag=veditor-config
    # config/veditor.php, .env: VEDITOR_LICENSE_KEY
  2. Add the editor to a form

    The @veditor directive renders the field, the styles and the script with the options from config/veditor.php.

    resources/views/articles/edit.blade.php
    <form method="post">
        @csrf
        @veditor('content', old('content', $article->body), ['height' => '400px'])
        <button>Save</button>
    </form>
  3. Sanitize on save

    VEditorService::sanitize() uses the same styles as the editor, so valid content passes unchanged.

    app/Http/Controllers/ArticleController.php
    public 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.

Full integration documentation

  • Blade directiveA directive rather than a component, so article content never goes through the Blade compiler.
  • Editor files from the packageGET /veditor/assets/{version}/{file}, only .js and .css, cached for a year.
  • AI endpointPOST /veditor/ai behind web and auth middleware, with the session’s CSRF token and StreamedResponse.
  • Roles and limitsaiFeaturesUsing() per user and beforeAiRequestUsing(), for example with RateLimiter.
  • 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.