PHP code example of mireon / yandex-turbo

1. Go to this page and download the library: Download mireon/yandex-turbo 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/ */

    

mireon / yandex-turbo example snippets




use Mireon\YandexTurbo\Channels\Articles\Articles;

// Fluent interface.
Articles::create()
    ->title('Название канала')
    ->description('Краткое описание канала')
    ->link('http://www.example.com/')
    ->language('ru');

// Classic style.
$channel = new Articles();
$channel->setTitle('Название канала');
$channel->setDescription('Краткое описание канала');
$channel->setLink('http://www.example.com/');
$channel->setLanguage('ru');




use Mireon\YandexTurbo\Channels\Articles\Analytic\Yandex\Yandex;

Yandex::create('id', 'params');

Yandex::createFromArray([
    'id' => '123456',
    'params' => "{ 'time' : 'now()' }",
]);

Yandex::createFromClosure(function (Yandex $yandex) {
    $yandex->id('123456');
    $yandex->params("{ 'time' : 'now()' }");
});




use Mireon\YandexTurbo\Channels\Articles\Articles;

Articles::create()
    ->title('Название канала')
    ->description('Краткое описание канала')
    ->link('http://www.example.com/')
    ->language('ru');



use Mireon\YandexTurbo\Channels\Articles\Articles;
use Mireon\YandexTurbo\Channels\Articles\Ad\Ads;
use Mireon\YandexTurbo\Channels\Articles\Ad\YandexAdNetwork\YandexAdNetwork;
use Mireon\YandexTurbo\Channels\Articles\Ad\AdFox\AdFox;

Articles::create()
    ->ad(YandexAdNetwork::create('id', 'turbo-ad-id'))
    ->ad(AdFox::create('turbo-ad-id', 'content'));

Articles::create()
    ->ads(Ads::create([
        YandexAdNetwork::create('id', 'turbo-ad-id'),
        AdFox::create('turbo-ad-id', 'content'),
    ]));



use Mireon\YandexTurbo\Channels\Articles\Articles;
use Mireon\YandexTurbo\Channels\Articles\Analytic\Custom\Custom;
use Mireon\YandexTurbo\Channels\Articles\Analytic\Google\Google;
use Mireon\YandexTurbo\Channels\Articles\Analytic\LiveInternet\LiveInternet;
use Mireon\YandexTurbo\Channels\Articles\Analytic\MailRu\MailRu;
use Mireon\YandexTurbo\Channels\Articles\Analytic\Mediascope\Mediascope;
use Mireon\YandexTurbo\Channels\Articles\Analytic\Rambler\Rambler;
use Mireon\YandexTurbo\Channels\Articles\Analytic\Yandex\Yandex;

Articles::create()
    ->analytic(Custom::create('url'))
    ->analytic(Google::create('id'))
    ->analytic(LiveInternet::create('params'))
    ->analytic(MailRu::create('id'))
    ->analytic(Mediascope::create('id'))
    ->analytic(Rambler::create('id'))
    ->analytic(Yandex::create('id', 'params'));

Articles::create()
    ->analytics(Analytics::create([
        Custom::create('url'),
        Google::create('id'),
        LiveInternet::create('params'),
        MailRu::create('id'),
        Mediascope::create('id'),
        Rambler::create('id'),
        Yandex::create('id', 'params'),
    ]));



use Mireon\YandexTurbo\Channels\Articles\Articles;
use Mireon\YandexTurbo\Channels\Articles\Item\Item;
use Mireon\YandexTurbo\Channels\Articles\Item\Items;

Articles::create()
    ->item(Item::create('link', 'content'))
    ->item(Item::create('link', 'content'))
    ->item(Item::create('link', 'content'));

Articles::create()
    ->items(Items::create([
        Item::create('link', 'content'),   
        Item::create('link', 'content'),   
        Item::create('link', 'content'),
    ]));

Articles::create()
    ->items(Items::createFromClosure(function (Items $items) {
        Item::create('link', 'content')->appendTo($items);
        Item::create('link', 'content')->appendTo($items);
        Item::create('link', 'content')->appendTo($items);
    }));



use Mireon\YandexTurbo\Channels\Articles\Item\Item;
use Mireon\YandexTurbo\Channels\Articles\Item\Metrics\Metrics;
use Mireon\YandexTurbo\Channels\Articles\Item\Metrics\Yandex\Breadcrumb;
use Mireon\YandexTurbo\Channels\Articles\Item\Metrics\Yandex\Yandex;
use Mireon\YandexTurbo\Channels\Articles\Item\RelatedLinks\RelatedLinks;
use Mireon\YandexTurbo\Channels\Articles\Item\RelatedLinks\Infinity\Link as InfinityLink;
use Mireon\YandexTurbo\Channels\Articles\Item\RelatedLinks\External\Link as ExternalLink;
use Mireon\YandexTurbo\Channels\Articles\Item\Content\Content;
use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Header\Header;

Item::create()
    ->turbo(true)
    ->link('url')
    ->source('url')
    ->topic('topic')
    ->pubDate('date')
    ->author('author')
    ->metrics(Metrics::create()
        ->metric(Yandex::create()
            ->id('123456')
            ->breadcrumb(Breadcrumb::create('text', 'url'))
            ->breadcrumb(Breadcrumb::create('text', 'url'))
        )
    )
    ->relatedLinks(RelatedLinks::create()
        ->link(InfinityLink::create('url'))
        ->link(ExternalLink::create('text', 'url', 'url'))
    )
    ->content(Content::create()
        ->block(Header::create()->title('title')->preview('url'))
        ->html('<div>Text</div>')
    );



use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Header\Header;
use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Header\Menu\Menu;
use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Header\Menu\Link as MenuLink;
use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Header\Breadcrumbs\Breadcrumbs;
use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Header\Breadcrumbs\Link as BreadcrumbsLink;

Header::create()
    ->title('text')
    ->subTitle('text')
    ->preview('url')
    ->menu(Menu::create()
        ->link(MenuLink::create('text', 'url'))
        ->link(MenuLink::create('text', 'url'))
        ->link(MenuLink::create('text', 'url'))
    )
    ->breadcrumbs(Breadcrumbs::create()
        ->link(BreadcrumbsLink::create('text', 'url'))
        ->link(BreadcrumbsLink::create('text', 'url'))
        ->link(BreadcrumbsLink::create('text', 'url'))
    );



use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Accordion\Accordion;
use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Accordion\Item;

Accordion::create()
    ->item(Item::create('title', 'content'))
    ->item(Item::create('title', 'content'))
    ->item(Item::create('title', 'content'));



use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Audio\Audio;

Audio::create()->src('url');



use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Slider\Slider;
use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Slider\Ad\Ad;
use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Slider\Image\Image;
use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Slider\Video\Video;

Slider::create()
    ->view(Slider::VIEW_LANDSCAPE)
    ->header('text')
    ->item(Ad::create()->turboAdId('turbo-ad-id'))
    ->item(Image::create()->image('url')->caption('text'))
    ->item(Video::create()
       ->width(400)
       ->height(200)
       ->source('url')
       ->type('mp4')
       ->duration(5)
       ->title('text')
       ->preview('url')
       ->caption('text')
    );



use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Cards\Cards;
use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Cards\Item;

Cards::create()
    ->item(Item::create()
        ->headerImage('url')
        ->headerTitle('text')
        ->content('text')
        ->footerUrl('url')
        ->footerText('text')
        ->moreUrl('url')
        ->moreText('text')
    );



use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Carousel\Carousel;
use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Carousel\Item;

Carousel::create()
    ->header('text')
    ->item(Item::create()->title('text')->image('url')->url('url'));



use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Fold\Fold;
use Mireon\YandexTurbo\Converter\StripTags;

Fold::create()->content('text')->converters([StripTags::class]);



use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Feed\Feed;
use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Feed\Item;

Feed::create()
    ->layout(Feed::LAYOUT_VERTICAL)
    ->title('text')
    ->item(Item::create()
        ->title('text')
        ->description('text')
        ->href('url')
        ->thumb('url')
        ->thumbPosition(Item::POSITION_RIGHT)
        ->thumbRatio(Item::RATIO_4x3)
    );



use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Ad\AdInContent;

AdInContent::create()->turboAdId('id')->mobile(true)->desktop(true);



use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Ad\AdInPage;

AdInPage::create()->turboAdId('id')->turboInPageAdId('id');



use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Button\Button;

Button::create()
    ->formaction('action')
    ->text('text')
    ->background('color')
    ->color('color')
    ->turbo(true)
    ->primary(false)
    ->disabled(false);



use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Search\Search;

Search::create()->action('action')->name('name')->placeholder('text');



use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Rating\Rating;

Rating::create()->value(5)->best(10);



use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Feedback\Feedback;
use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Feedback\Item;

Feedback::create()
    ->title('text')
    ->stick(Feedback::STICK_RIGHT)
    ->item(Item::create()
        ->type(Item::TYPE_CALLBACK)
        ->url('url')
        ->sendTo('email')
        ->agreementCompany('company')
        ->agreementLink('url')
    );



use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Share\Share;

Share::create()
    ->network(Share::NETWORK_FACEBOOK)
    ->network(Share::NETWORK_ODNOKLASSNIKI)
    ->network(Share::NETWORK_TELEGRAM)
    ->network(Share::NETWORK_TWITTER)
    ->network(Share::NETWORK_VKONTAKTE);



use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Comments\Comments;
use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Comments\Comment;

Comments::create()
    ->url('url')
    ->item(Comment::create()
        ->author('text')
        ->subTitle('text')
        ->header('text')
        ->content('text')
        ->avatar('url')
    );



use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Callback\Callback;

Callback::create()
    ->sendTo('email')
    ->agreement('company', 'url');



use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\DynamicForm\DynamicForm;
use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\DynamicForm\Checkbox\Checkbox;
use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\DynamicForm\Input\Input;
use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\DynamicForm\Radio\Radio;
use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\DynamicForm\Radio\Option as RadioOption;
use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\DynamicForm\Select\Select;
use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\DynamicForm\Select\Option as SelectOption;
use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\DynamicForm\Textarea\Textarea;

DynamicForm::create()
    ->endPoint('url')
    ->item(Checkbox::create()
        ->name('text')
        ->value('text')
        ->content('text')
    )
    ->item(Input::create()
        ->type(Input::TYPE_TEXT)
        ->name('text')
        ->label('text')
        ->placeholder('text')
        ->



use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Histogram\Histogram;
use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Histogram\Item;

Histogram::create()
    ->item(Item::create()
        ->title('text')
        ->value(10)
        ->height(50)
        ->icon('url')
        ->color('color')
    );



use Mireon\YandexTurbo\Channels\Articles\Item\Content\Blocks\Html\Html;
use Mireon\YandexTurbo\Converter\StripTags;
use Mireon\YandexTurbo\Converter\WrapP;

Html::create()
    ->html('<div>Hello world!</div>')
    ->converters([StripTags::class, WrapP::class]);



use Mireon\YandexTurbo\Channels\Articles\Articles;

header('Content-Type: text/xml; charset=utf-8');

print Articles::create()->render();