PHPackages                             verstka/php-sdk - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. verstka/php-sdk

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

verstka/php-sdk
===============

Verstka PHP sdk

1.1.3(2y ago)81.3k1LGPL-3.0-or-laterPHPPHP &gt;=7.1

Since Jun 4Pushed 2y ago3 watchersCompare

[ Source](https://github.com/verstka/php-sdk)[ Packagist](https://packagist.org/packages/verstka/php-sdk)[ RSS](/packages/verstka-php-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (18)Used By (0)

Verstka Editor PHP-SDK
======================

[](#verstka-editor-php-sdk)

First, You need to require package by composer with composer require verstka/php-sdk

Initialization via config
-------------------------

[](#initialization-via-config)

```
$verstkaBuilder = new \Verstka\EditorApi\Builder\VerstkaConfigBuilder(
    'API_KEY_FRsGhsgFGSG45d34',
    'SECRET_KEY_32ff2f23f32f',
    'aws-host.toexternal_storage.com',          // Optional, image storage host
    'https://verstka.org',                      // Optional, Verstka API url
    true,                                       // Optional, Debug mode
  );

$verstkaEditor  = $verstkaBuilder->build();
```

Initialization with ENV
-----------------------

[](#initialization-with-env)

```
$verstkaBuilder = new \Verstka\EditorApi\Builder\VerstkaEnvBuilder();

$verstkaEditor  = $verstkaBuilder->build();
```

set `.env` file in the root of your project with settings listed below:

```
verstka_apikey = "..."
verstka_secret = "..."
verstka_host = "https://verstka.org"

```

if you don't use vlucas/phpdotenv or yiithings/yii2-dotenv or something like that just set environment before new object of Verstka create:

```
putenv('verstka_apikey=...');
putenv('verstka_secret=...');
putenv('verstka_host=https://verstka.org');

```

additional parameters:

```
images_host - in case if you use relative images
and storage host different from callback url host

```

Editing an article
------------------

[](#editing-an-article)

```
$sql = 'SELECT * FROM t_materials WHERE name = :name';
$article = static::getDatabase()->fetchOne($sql, ['name' => $material_id]);

$body = $is_mobile ? $article['mobile_html'] : $article['desktop_html'];

$custom_fileds = [
    'auth_user' => 'test',                                      //if you have http authorization on callback url
    'auth_pw' => 'test',                                        //if you have http authorization on callback url
    'fonts.css' => 'https://mydomain.com/static/vms_fonts.css', //if you use custom fonts set
    'mobile' => true                                            //if you open mobile version of the post,
    'user_id' => 123                                            //if you want to know the user who opened the editor when saving
];
```

for example and then just:

```
/// ....
$verstkaEditor  = $verstkaBuilder->build();

$verstka_url = $verstkaEditor->open(
    $material_id,
    $body,
    $is_mobile,
    'https://mydomain.com/verstka/save',
    $custom_fileds
);
```

Saving an article
-----------------

[](#saving-an-article)

Save with MaterialSaverInterface implementation

And check out the interface \\Verstka\\EditorApi\\Image\\ImagesLoaderInterface, which loads images of material into your storage.

```
///  ....
$verstkaEditor = $verstkaBuilder->build();
$materialSaver = new MaterialSaver(); // your saver \Verstka\EditorApi\Material\MaterialSaverInterface

// Prepare data
$data = new \Verstka\EditorApi\Material\MaterialData($arrayData); // Material data from POST

return $verstkaEditor->save($materialSaver, $data);
```

Saving an article with old Callback api

```
///  ....
$verstkaEditor = $verstkaBuilder->build();
$materialSaver = new MaterialSaver(); // your saver \Verstka\EditorApi\Material\MaterialSaverInterface

// Prepare data
$data = new \Verstka\EditorApi\Material\MaterialData($arrayData); // Material data from POST

return $verstkaEditor->save(function(array|\Verstka\EditorApi\Material\MaterialDataInterface $data): bool
{

    $is_fail = false;
    $article_body = $data['article_body'];
    $article_static_dir_rel = sprintf('/upload/verstka/%s%s', $data['is_mobile'] ? 'm_':'', $data['material_id']);
    $article_static_dir_abs = sprintf('%s%s%s%s', WEBROOT, DIRECTORY_SEPARATOR, '/public/', $article_static_dir_rel);
    @mkdir($article_static_dir_abs,  0777, true);
    foreach ($data['images'] as $image_name => $imageTmpFilePath) {
        $is_renamed = rename($imageTmpFilePath, sprintf('%s/%s', $article_static_dir_abs, $image_name));
        $is_fail = $is_fail || !$is_renamed;
        $html_image_name_old = sprintf('/vms_images/%s', $image_name);
        $html_image_name_new = sprintf('%s/%s', $article_static_dir_rel, $image_name);
        if ($is_renamed) {
            $article_body = str_replace($html_image_name_old, $html_image_name_new, $article_body);
        }
    }

    if ($is_fail) {
        return false; //tell editor that save goes wrong
    }

    if ($data['is_mobile']) {
        $sql = 'update t_materials set mobile_html =  :article_body where name = :name;';
    } else {
        $sql = 'update t_materials set desktop_html = :article_body where name = :name;';
    }

    $db = Plugin::getDatabase();
    $saved = (bool)$db->fetchAffected($sql, ['article_body' => $article_body, 'name' => $data['material_id']]);
    $is_fail = $is_fail || !$saved;

    return !$is_fail;
}, $data);
```

Use your own fonts
------------------

[](#use-your-own-fonts)

You need to collect a CSS file with certain comments and fonts sewn into base64, and then they will automatically appear in the Layout. default url /vms\_fonts.css

At the top of the CSS file you need to specify the default font in the comments, which will be set when creating a new text object.

```
/* default_font_family: 'formular'; */
/* default_font_weight: 400; */
/* default_font_size: 16px; */
/* default_line_height: 24px; */
```

Further, for each `@ font-face` it is necessary to register comments with the name of the font and its style.

```
/* font_name: 'Formular'; */
/* font_style_name: 'Light'; */
```

Final CSS file:

```
/* default_font_family: 'formular'; */
/* default_font_weight: 400; */
/* default_font_size: 16px; */
/* default_line_height: 24px; */

@ font-face {
    /* font_name: 'Formular'; */
    /* font_style_name: 'Light'; */
    font-family: 'formular';
    src: url (data: application / font-woff2;
    charset = utf-8;
    base64, KJHGKJHG . . .) format ('woff2'), url (data: application / font-woff;
    charset = utf-8;
    base64, KJHGKJHGJ . . .) format ('woff');
    font-weight: 300;
    font-style: normal;
}

@ font-face {
    /* font_name: 'Formular'; */
    /* font_style_name: 'Regular; */
    font-family: 'formular';
    src: url (data: application / font-woff2;
    charset = utf-8;
    base64, AAFEWDDWEDD . . .) format ('woff2'), url (data: application / font-woff;
    charset = utf-8;
    base64, AAFEWDDWEDD . . .) format ('woff');
    font-weight: 400;
    font-style: normal;
}
```

Displaying Articles
-------------------

[](#displaying-articles)

The HTML code of the article should be accompanied by the connection of the script:

```

    window.onVMSAPIReady = function (api) {
        api.Article.enable ({
            display_mode: 'default'
        });
    };

```

### Options `options`

[](#options-options)

#### All parameters are optional.

[](#all-parameters-are-optional)

- `observe_selector` - selector of element that can potentially change position of the article. For example, selector of a banner, that can push an article down.

#### Further parameters if it is impossible to type out a separate mobile version:

[](#further-parameters-if-it-is-impossible-to-type-out-a-separate-mobile-version)

- `display_mode` - switches between article display modes, please set `default`;

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 74.1% 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 ~35 days

Total

16

Last Release

909d ago

Major Versions

0.0.8 → 1.0.02022-07-14

### Community

Maintainers

![](https://www.gravatar.com/avatar/af89acae898eee9f61367d880b01a9dd4ac66297b06f4b2a32764f8f42f8a410?d=identicon)[puzatkin-ivan](/maintainers/puzatkin-ivan)

![](https://www.gravatar.com/avatar/161e087bf45a20c323a6e585c3061c5eaa3d1aabe9d1fd2467e98c0241c9224f?d=identicon)[tychodaimon](/maintainers/tychodaimon)

---

Top Contributors

[![tychodaimon](https://avatars.githubusercontent.com/u/3998058?v=4)](https://github.com/tychodaimon "tychodaimon (43 commits)")[![puzatkin-ivan](https://avatars.githubusercontent.com/u/24225776?v=4)](https://github.com/puzatkin-ivan "puzatkin-ivan (15 commits)")

### Embed Badge

![Health badge](/badges/verstka-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/verstka-php-sdk/health.svg)](https://phpackages.com/packages/verstka-php-sdk)
```

###  Alternatives

[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

4.8k4.3k](/packages/shlinkio-shlink)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[dhlparcel/magento2-plugin

DHL Parcel plugin for Magento 2

11180.5k2](/packages/dhlparcel-magento2-plugin)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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