Installation
Requirements
- A browser with ES module support (current Chrome, Edge, Firefox, Safari). The licence signature is checked with WebCrypto, which needs HTTPS (or
localhost). - PHP 8.1+ with
dom,libxmlandmbstring;opensslfor the licence signature check on the server;curlfor the AI functions. - The Laravel and Symfony packages need PHP 8.2+.
Composer
VEditor is distributed through a private Composer repository. Your licence key is the password; to test before buying, use a free trial key.
composer config repositories.veditor composer https://packages.veditor.eu
composer config http-basic.packages.veditor.eu license <licence-key>
composer require veditor/veditor
The user name is not checked; license is a good convention. In CI, use the COMPOSER_AUTH environment variable instead of auth.json in the repository.
With the Laravel or Symfony integration, require veditor/laravel or veditor/symfony-bundle instead: the editor files are then served from the package and nothing has to be copied.
Without a framework integration, the browser files live in vendor/veditor/veditor/assets/. Copy them (or link them) to a public directory, for example public/veditor/, and repeat that after every update.
Without Composer
Download the ZIP of the newest version covered by your licence from your order page (the link is in the e-mail you get after the purchase). Unpack the release ZIP outside the public web directory, include autoload.php and make only the assets/ directory public (copy or link it, for example to public/veditor/). Keep the server configuration with your keys outside the web directory too and point VEDITOR_CONFIG to it. If the package must live under the web root, deny everything except assets/ (the src/ directory already has an .htaccess; on nginx deny it in the server block).
require __DIR__ . '/veditor/autoload.php';
The AI functions need the server configuration: copy config.dist.php to config.php in the package directory, or point the VEDITOR_CONFIG constant or environment variable to a file outside it. See Server configuration.
React and Vue (npm)
For React and Vue, install the component from the npm registry:
npm install @veditor.eu/react
npm install @veditor.eu/vue
The npm package contains only the component: it loads the editor itself from your server, so install the server part first with Composer or from the ZIP, as described above. Details: React, Vue.
First editor
<link rel="stylesheet" href="/veditor/veditor-content.css">
<link rel="stylesheet" href="/veditor/veditor.css">
<form method="post">
<textarea name="content" id="content"><?= htmlspecialchars($html) ?></textarea>
<button type="submit">Save</button>
</form>
<script type="module">
import { VEditor } from '/veditor/js/index.js';
window.editor = await VEditor.create('#content', {
language: 'en',
licenseKey: 'VED1.…', // your key; leave it out on local and test addresses
});
</script>
And on the server, before saving:
use VEditor\HtmlSanitizer;
try {
$clean = (new HtmlSanitizer())->sanitize((string) $_POST['content']);
} catch (LengthException $e) {
// larger than maxLength (1 MB by default)
}
Show the content inside an element with the veditor-content class and include veditor-content.css on that page:
<div class="veditor-content"><?= $clean ?></div>
Updating
composer update veditor/* installs the latest version your licence covers. After an update, clear the browser cache of the editor files if you copy them yourself; the Laravel and Symfony integrations put the version in the address and Yii2 publishes the files under a new hash, so browsers fetch the new files automatically.
Next steps
- Editor options
- Server configuration for the licence and AI
- HTML sanitizer
Something unclear? Send feedback on the documentation.