PHPackages                             imponeer/editor-contracts - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. imponeer/editor-contracts

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

imponeer/editor-contracts
=========================

Interfaces for building PHP classes that lets to easier make web editor integrations in your content management systems

v1.1.3(1mo ago)019.4k↓75%1MITPHPPHP &gt;=8.3CI passing

Since Oct 12Pushed 3w ago2 watchersCompare

[ Source](https://github.com/imponeer/editor-contracts)[ Packagist](https://packagist.org/packages/imponeer/editor-contracts)[ RSS](/packages/imponeer-editor-contracts/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (4)Versions (19)Used By (1)

Editor Contracts
================

[](#editor-contracts)

[![License](https://camo.githubusercontent.com/69c50e389591c48dae1c8224f4625119907558d9dc2f279a0c5244c838e69d9c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f696d706f6e6565722f656469746f722d636f6e7472616374732e737667)](LICENSE)[![GitHub release](https://camo.githubusercontent.com/5b66cb44db54486ab5c46c5065953138e50eb261efbc65e7cd08646403fe5e8f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f696d706f6e6565722f656469746f722d636f6e7472616374732e737667)](https://github.com/imponeer/editor-contracts/releases)[![PHP](https://camo.githubusercontent.com/200f926354e40d01286a42e816766f95a88b8f146f4ea47beafc79df1436d03a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f696d706f6e6565722f656469746f722d636f6e7472616374732e737667)](http://php.net)[![Packagist](https://camo.githubusercontent.com/50e0fcaaa6e266d8463b1a24250843d74c6b435207554e68b95d792b8916d0e7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f696d706f6e6565722f656469746f722d636f6e7472616374732e737667)](https://packagist.org/packages/imponeer/editor-contracts)

PHP interfaces and contracts for integrating web editors into content management systems. Defines common interfaces for editor adapters, factories, and metadata to standardize how different editor types (WYSIWYG, source code editors) are implemented and used.

📦 Installation
--------------

[](#-installation)

Install the package via [Composer](https://getcomposer.org):

```
composer require imponeer/editor-contracts
```

🏗️ Architecture Overview
------------------------

[](#️-architecture-overview)

This library follows a clean architecture pattern with the following key components:

### Core Interfaces

[](#core-interfaces)

- **`EditorAdapterInterface`** - Main contract for renderable editor instances
- **`EditorFactoryInterface`** - Factory pattern for creating editor instances
- **`EditorInfoInterface`** - Base contract for editor metadata and capabilities
- **`SourceEditorInfoInterface`** - Extended contract for source code editors
- **`WYSIWYGEditorInfoInterface`** - Extended contract for WYSIWYG editors

### Exception Handling

[](#exception-handling)

- **`IncompatibleEditorException`** - Thrown when editor configuration validation fails

🚀 Usage Examples
----------------

[](#-usage-examples)

### Implementing an Editor Adapter

[](#implementing-an-editor-adapter)

```
use Imponeer\Contracts\Editor\Adapter\EditorAdapterInterface;

class MyCustomEditor implements EditorAdapterInterface
{
    public function getAttributes(): array
    {
        return [
            'id' => 'my-editor',
            'class' => 'custom-editor',
            'data-editor' => 'my-custom-editor'
        ];
    }

    public function getStyleURLs(): array
    {
        return [
            'https://cdn.example.com/editor/styles.css',
            '/assets/custom-editor.css'
        ];
    }

    public function getScriptURLs(): array
    {
        return [
            'https://cdn.example.com/editor/editor.min.js'
        ];
    }

    public function getScriptCode(): string
    {
        return 'MyEditor.init("my-editor", {theme: "modern"});';
    }

    public function __toString(): string
    {
        return '';
    }
}
```

### Creating an Editor Factory

[](#creating-an-editor-factory)

```
use Imponeer\Contracts\Editor\Factory\EditorFactoryInterface;
use Imponeer\Contracts\Editor\Adapter\EditorAdapterInterface;
use Imponeer\Contracts\Editor\Info\EditorInfoInterface;
use Imponeer\Contracts\Editor\Exceptions\IncompatibleEditorException;

class MyEditorFactory implements EditorFactoryInterface
{
    public function getInfo(): EditorInfoInterface
    {
        return new MyEditorInfo();
    }

    public function create(array $config, bool $checkCompatible = false): EditorAdapterInterface
    {
        if ($checkCompatible && !$this->isConfigValid($config)) {
            throw new IncompatibleEditorException('Invalid configuration provided');
        }

        return new MyCustomEditor($config);
    }

    private function isConfigValid(array $config): bool
    {
        // Implement your validation logic
        return isset($config['theme']) && is_string($config['theme']);
    }
}
```

### Implementing Editor Info

[](#implementing-editor-info)

```
use Imponeer\Contracts\Editor\Info\WYSIWYGEditorInfoInterface;

class MyEditorInfo implements WYSIWYGEditorInfoInterface
{
    public function getName(): string
    {
        return 'My Custom WYSIWYG Editor';
    }

    public function isAvailable(): bool
    {
        // Check if editor assets are available
        return file_exists('/path/to/editor/assets');
    }

    public function getVersion(): string
    {
        return '1.0.0';
    }

    public function getLicense(): string
    {
        return 'MIT';
    }
}
```

### Using in Your Application

[](#using-in-your-application)

```
// Create factory
$factory = new MyEditorFactory();

// Get editor info
$info = $factory->getInfo();
echo "Editor: " . $info->getName() . " v" . $info->getVersion();

// Create editor instance
$config = ['theme' => 'dark', 'toolbar' => 'full'];
$editor = $factory->create($config, true);

// Render in your template
echo '';
foreach ($editor->getStyleURLs() as $styleUrl) {
    echo '';
}
echo '';

echo $editor; // Renders the editor HTML

foreach ($editor->getScriptURLs() as $scriptUrl) {
    echo '';
}
echo '' . $editor->getScriptCode() . '';
echo '';
```

🔧 Development
-------------

[](#-development)

### Code Quality Tools

[](#code-quality-tools)

This project uses several tools to maintain code quality:

#### PHP CodeSniffer (PSR-12 compliance)

[](#php-codesniffer-psr-12-compliance)

```
composer phpcs
```

#### Fix coding standard violations

[](#fix-coding-standard-violations)

```
composer phpcbf
```

#### PHPStan static analysis (level max)

[](#phpstan-static-analysis-level-max)

```
composer phpstan
```

### Testing

[](#testing)

The project includes GitHub Actions CI/CD pipeline that:

- Tests on multiple PHP versions
- Validates composer.json
- Runs code style checks
- Performs static analysis

### API Documentation

[](#api-documentation)

For detailed API documentation, please visit the [Wiki](https://github.com/imponeer/editor-contracts/wiki).

🤝 Contributing
--------------

[](#-contributing)

We welcome contributions! Here's how you can help:

### Getting Started

[](#getting-started)

1. Fork the repository
2. Create a feature branch: `git checkout -b feature/amazing-feature`
3. Make your changes
4. Run code quality checks: `composer phpcs && composer phpstan`
5. Commit your changes: `git commit -m 'Add amazing feature'`
6. Push to the branch: `git push origin feature/amazing-feature`
7. Open a Pull Request

### Guidelines

[](#guidelines)

- Follow PSR-12 coding standards
- Add PHPDoc comments for all public methods
- Ensure PHPStan level max compliance
- Write clear commit messages
- Update documentation if needed

### Reporting Issues

[](#reporting-issues)

Found a bug or have a suggestion? Please use the [issues tab](https://github.com/imponeer/editor-contracts/issues) to:

- Report bugs with detailed reproduction steps
- Suggest new features or improvements
- Ask questions about usage

###  Health Score

56

—

FairBetter than 97% of packages

Maintenance94

Actively maintained with recent releases

Popularity24

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 51% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~130 days

Recently: every ~238 days

Total

14

Last Release

32d ago

PHP version history (2 changes)v1.0.0PHP &gt;=7.1

v1.1.0PHP &gt;=8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/dba53e399a507d1f60626164c8b1e340a5cc0dc4f0637f4c6aaff8fc239fdaee?d=identicon)[fiammybe](/maintainers/fiammybe)

![](https://avatars.githubusercontent.com/u/342641?v=4)[Raimondas Rimkevičius](/maintainers/MekDrop)[@MekDrop](https://github.com/MekDrop)

![](https://avatars.githubusercontent.com/u/2429107?v=4)[Steve Kenow](/maintainers/skenow)[@skenow](https://github.com/skenow)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (49 commits)")[![MekDrop](https://avatars.githubusercontent.com/u/342641?v=4)](https://github.com/MekDrop "MekDrop (42 commits)")[![Codex](https://avatars.githubusercontent.com/in/2248422?v=4)](https://github.com/Codex "Codex (2 commits)")[![fiammybe](https://avatars.githubusercontent.com/u/3736946?v=4)](https://github.com/fiammybe "fiammybe (2 commits)")[![mend-bolt-for-github[bot]](https://avatars.githubusercontent.com/in/16809?v=4)](https://github.com/mend-bolt-for-github[bot] "mend-bolt-for-github[bot] (1 commits)")

---

Tags

contractseditorhacktoberfestinterfaces

###  Code Quality

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/imponeer-editor-contracts/health.svg)

```
[![Health](https://phpackages.com/badges/imponeer-editor-contracts/health.svg)](https://phpackages.com/packages/imponeer-editor-contracts)
```

###  Alternatives

[maclof/kubernetes-client

A simple yet elegant client for accessing and controlling a Kubernetes cluster.

237916.9k5](/packages/maclof-kubernetes-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
