PHP code example of manzadey / sbuilder-xml-soap

1. Go to this page and download the library: Download manzadey/sbuilder-xml-soap library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

manzadey / sbuilder-xml-soap example snippets


use Manzadey\SBuilderXmlSoap\Plugins;
use Manzadey\SBuilderXmlSoap\Plugin;
use Manzadey\SBuilderXmlSoap\Category;
use Manzadey\SBuilderXmlSoap\Field;
use Manzadey\SBuilderXmlSoap\Element;

$plugins = new Plugins;

$plugin14 = new Plugin('pl_plugin_14');

$category1400 = new Category('1400');
$category1400->addField('cat_title', 'Раздел 1');
$category1400->addField(new Field('user_f_17', 'Наполнение для поля user_f_17'));
$category1400->addField(
    static fn(Category $category) : Field => $category
        ->newField('user_f_19', 'Наполнение для поля user_f_19')
);

$element = new Element;
$element->addField('p_title', 'Элемент 1');
$element->addField('p_price1', '10000');
$element->addField('p_active', '1');
$element->addField('user_f_18', 'Наполнение для поля user_f_18');

$category1400->addElement($element);
$category1400->addCategory(
    static fn(Category $category) : Category => $category->newCategory()
        ->addField('cat_title', 'Подраздел раздела 1')
        ->addField('user_f_17', 'Наполнение для поля user_f_17')
        ->addField('user_f_19', 'Наполнение для поля user_f_19')
        ->addElement(static fn(Category $category) : Element => $category
            ->newElement()
            ->addField('p_title', 'Элемент 2')
            ->addField('p_price1', '20000')
            ->addField('p_active', '1')
            ->addField('user_f_18', 'Наполнение для поля user_f_18')
            ->addField(static fn(Element $element) : Field => $element
                ->newField('user_f_4', '5')
                ->extId()
            )
        )
);

$plugin14->addCategory($category1400);
$plugins->addPlugin($plugin14);

echo $plugins->save();

use Manzadey\SBuilderXmlSoap\Plugins;
use Manzadey\SBuilderXmlSoap\Plugin;
use Manzadey\SBuilderXmlSoap\Category;
use Manzadey\SBuilderXmlSoap\Field;
use Manzadey\SBuilderXmlSoap\Element;

$plugins = (new Plugins)->addPlugin(
    static fn(Plugins $plugins) : Plugin => $plugins->newPlugin('pl_plugin_14')
        ->addCategory(
            static fn(Plugin $plugin) : Category => $plugin->newCategory()
                ->addField('cat_title', 'Новинки')
                ->addElement(
                    static fn(Category $category) : Element => $category->newElement()
                        ->addField('p_title', 'Мобильный телефон')
                        ->addField('p_price_1', '10000')
                        ->addField(
                            static fn(Element $element) : Field => $element->newField('user_f_22', '4')->extId()
                        )
                )
        )
)->newPlugin(
    'pl_sprav',
    static fn(Plugin $plugin) : Plugin => $plugin->addCategory(
            static fn(Plugin $plugin) : Category => $plugin->newCategory()
                ->addField('cat_title', 'Цвета')
                ->addField('show_prop1', '1')
                ->addField('show_prop2', '0')
                ->addField('show_prop3', '0')
                ->addElement(
                    static fn(Category $category) : Element => $category->newElement()
                        ->addField('s_title', 'Красный')
                        ->addField('s_prop_1', 'red')
                        ->addField('s_ext_id', '4')
                )->addElement(
                    static fn(Category $category) : Element => $category->newElement(extId: 5)
                        ->addField('s_title', 'Зеленый')
                        ->addField('s_prop_1', 'green')
                        ->addField('s_ext_id', '5')
                )
        )
);

use Manzadey\SBuilderXmlSoap\Plugins;
use Manzadey\SBuilderXmlSoap\Plugin;
use Manzadey\SBuilderXmlSoap\Category;
use Manzadey\SBuilderXmlSoap\Element;

$plugins = (new Plugins)->addPlugin(
    static fn(Plugins $plugins) : Plugin => $plugins
        ->newPlugin('pl_plugin_14')
        ->addCategory(static fn(Plugin $plugin) : Category => $plugin
            ->newCategory('2175')
            ->delete()
            ->addField('cat_title', 'Новинки')
            ->addElement(
                static fn(Category $category) : Element => $category
                    ->newElement(extId: 12)
                    ->addField('p_title', 'Мобильный телефон')
            )
        )
);

echo $plugins->save();

$plugins->upload('https://url.to/soap/client', 'token');