承接 mvo/me-like 相关项目开发

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

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

mvo/me-like

Composer 安装命令:

composer require mvo/me-like

包简介

Let users like things, confirm their likes via email and keep track of the count.

README 文档

README

Demo

What does it do?

This bundle provides a widget that users can click on to like things (backed by an API).

Likes need to be confirmed in order to count - this is accomplished by asking for an email address and sending an email with a link to confirm the like. This doubles as a constraint: each user (email) can only like (each endpoint) once.

There can be multiple endpoints/domains (= things to like) that are identified by a unique string. This can e.g. be a single one (idea), or a fixed or dynamic list (project.1, project.2, …) - the system actually doesn't care. It will ask your code if a given endpoint is valid when listing/adding/confirming likes.

The js widget talks to the server system via an API endpoint. It also acts as a proxy for confirming likes. For this to work, we define a distinct URL fragment for the widget listens on that contains the 'confirm token' (same holds true for the user token; see below).

Security & privacy

  • The email addresses itself are never stored - only a one way hash of them. Plus: the hash is unique for every endpoint and system.
  • The API does not allow checking if a certain email address has already 'liked' the endpoint. The widget (client side), however, acquires a token and stores it in localstorage when requesting a new like. This token allows it to query information about the user's like (and therefore can provide a nicer UI).
  • The user token gets appended to the 'confirm url' allowing the widget to read it and refresh the local version.

Stored things on the server

  • a table of hashed emails (see Like entity) in your database

Stored things at the client

  • a user token (localstorage)

Setup

  1. Require the bundle and register it.

    composer require mvo/me-like
  2. Render the widget to the desired endpoint in your twig template:

    {{ render(controller('mvo.me_like.widget', { 'endpoint': 'my-endpoint' })) }}
  3. Add an endpoint handler (implementing Mvo\MeLike\Endpoint\EndpointInterface) that returns VALID for the endpoints you want to allow. You can also add random data context to the endpoint that will be available in the notification template.

     class MyEndpoint implements EndpointValidatorInterface
     {
         public function handle(string $domain, ?int $id): ?bool
         {
             return 'my-endpoint' === $domain ? 
                 EndpointValidatorInterface::VALID : 
                 EndpointValidatorInterface::UNKOWN;
         }
    
        public function addContext(string $domain, ?int $id): ?array
        {
             return null;
        }
     }   

    In case your endpoint's name is in the form <domain>.<id> the individual parts will be passed to your handler.

    Note that a handler will only be asked to add context for an endpoint if handle() returns VALID for this endpoint. You do not need to re-check the validity inside addContext().

  4. If you're not using autoconfiguration, tag the handler it with mvo_me_like.endpoint.

  5. Make sure to load the js widget and minimal styles. The bundle ships with a compiled version (like_widget.js, like_widget.css) which automatically initializes the widgets and has some opinionated styles. Feel free to build your own version (see sources under /layout).

Configuration

  1. The systems sends emails via symfony mailer. Configure the following templates and config keys to fit your needs:

    • Notification template: @MvoMeLike\Email\confirm_like.html.twig
    • Mailer config:
      mvo_me_like:
        notification:
            email_from: 'mail@example.com'
  2. Adapt translations to your needs. The email subject can also be modified this way. If you need context sensitive parameters pass them in your endpoint handler under the key email_subject.

  3. You can also configure the token names (user token + confirm token) that are appended to the URL (e.g. in case you've got some anchors with the same names):

    mvo_me_like:
      user_token: 'tok_u'
      confirm_token: 'tok_c'

    This will result in a 'confirm url' like so: https://example.com/some/site#tok_u=&tok_c=

    All tokens have a length of 64 characters.

mvo/me-like 适用场景与选型建议

mvo/me-like 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 559 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 04 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「email」 「like」 「confirm」 「vote」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 mvo/me-like 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mvo/me-like 我们能提供哪些服务?
定制开发 / 二次开发

基于 mvo/me-like 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-04-24