承接 bigoen/mercure-twig-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bigoen/mercure-twig-bundle

Composer 安装命令:

composer require bigoen/mercure-twig-bundle

包简介

Mercure twig bundle.

README 文档

README

Developed based on https://github.com/sroze/live-twig package.

Install:

composer require bigoen/mercure-twig-bundle

If you don't use Symfony Flex:

.env.local

###> bigoen/mercure-twig-bundle ###
MERCURE_TWIG_PUBLISH_URL=http://mercure/.well-known/mercure
###< bigoen/mercure-twig-bundle ###

config/bundles.php

return [
    // ...
    Bigoen\MercureTwigBundle\BigoenMercureTwigBundle::class => ['all' => true],
];

config/packages/bigoen_mercure_twig.yaml

bigoen_mercure_twig:
    public_url: "%env(MERCURE_TWIG_PUBLISH_URL)%"
    # subscriber_js: '@BigoenMercureTwig\subscriber_js.html.twig'

How to use?

Configurations:

  • Set MERCURE_TWIG_PUBLISH_URL,
  • Set subscriber_js in yaml configuration. Default: '@BigoenMercureTwig\subscriber_js.html.twig'

Publisher Example:

use Symfony\Component\Mercure\PublisherInterface;
use Symfony\Component\Mercure\Update;

/** @var PublisherInterface $publisher */
$publisher(new Update('live', 'test'));

Controller Example:

<?php

declare(strict_types=1);

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

/**
 * @Route("/mercure", name="mercure.")
 */
class MercureController extends AbstractController
{
    /**
     * @Route("/order", name="order")
     */
    public function orderAction(): Response
    {
        return $this->render('mercure/order.html.twig');
    }
}

Twig Example:

  • Set render controller,
  • Set mercure topics,
  • Set token is private.
  • Set isAdd. Default: 0. 1 = afterbegin, 2 = beforebegin.
{{ render_bigoen_mercure_twig(
    controller('App\\Controller\\MercureController::orderAction'),
    {'topics': ['live'], 'isAdd': 1, 'token': 'bearer token'}
) }}

统计信息

  • 总下载量: 156
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0
  • 更新时间: 2020-12-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固