定制 abderrahimghazali/sylius-popup-plugin 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

abderrahimghazali/sylius-popup-plugin

Composer 安装命令:

composer require abderrahimghazali/sylius-popup-plugin

包简介

Exit-intent & engagement popup system for Sylius 2.x stores, fully managed from the admin panel.

README 文档

README

Sylius Logo

Sylius Popup Plugin

Exit-intent & engagement popup system for Sylius 2.x stores, fully managed from the admin panel.

CI Latest Version PHP Version License Sylius 2.x Symfony 7.x PHPStan Level 5

Screenshots

Admin — Campaign List

Admin Grid

Admin — Edit Campaign (Tabbed Form)

Admin Form

Shop — Modal Popup (Exit Intent)

Popup Modal

Features

  • Multiple popup campaigns — create, enable/disable, and prioritize from the admin panel
  • 4 trigger types:
    • Exit intent (mouseleave detection)
    • Time on page (configurable delay in seconds)
    • Scroll depth (configurable percentage)
    • Cart abandonment (exit intent only when cart has items)
  • Smart frequency control — show once per session, per 24h, or per 7 days (localStorage)
  • Page targeting — all pages, product pages, cart, or checkout
  • Audience targeting — everyone, guests only, or logged-in users only
  • 2 popup styles — centered modal with overlay, or fixed bottom bar
  • Discount codes — display a copyable code with one-click copy (Clipboard API)
  • Email capture — optional email field that POSTs to a dedicated API endpoint and dispatches a sylius_popup.email_captured event for 3rd-party integrations
  • Full design control — background color, text color, button color (HTML color picker in admin)
  • Rate-limited API — email subscribe endpoint limited to 3 requests/IP/hour
  • No external JS — pure vanilla JS via Stimulus controller
  • Twig hooks — auto-injects into the shop layout, no template overrides needed

Requirements

  • Sylius 2.1+
  • Symfony 7.0+
  • PHP 8.2+

Installation

  1. Require the plugin:
composer require abderrahimghazali/sylius-popup-plugin
  1. Register the bundle in config/bundles.php (if not auto-discovered):
return [
    // ...
    Abderrahim\SyliusPopupPlugin\SyliusPopupPlugin::class => ['all' => true],
];
  1. Import routes — create config/routes/sylius_popup.yaml:
sylius_popup:
    resource: '@SyliusPopupPlugin/config/routes.yaml'
  1. Generate and run the migration:
bin/console doctrine:migrations:diff
bin/console doctrine:migrations:migrate
  1. Register the Stimulus controller in assets/shop/controllers.json:
{
    "controllers": {
        "@abderrahimghazali/sylius-popup-plugin": {
            "popup": {
                "enabled": true,
                "fetch": "eager"
            }
        }
    }
}
  1. Symlink the plugin assets and rebuild:
# Create the symlink (from your project root)
mkdir -p node_modules/@abderrahimghazali
ln -s ../../vendor/abderrahimghazali/sylius-popup-plugin/assets node_modules/@abderrahimghazali/sylius-popup-plugin

# Rebuild assets
yarn encore dev

Usage

Admin Panel

Navigate to Marketing > Popup Campaigns in the Sylius admin sidebar.

Create a new campaign with three configuration tabs:

Tab Fields
Content Name, title, body text, CTA button label & URL, discount code, email capture toggle
Design Style (modal/bar), background color, text color, button color
Targeting Trigger type & params, show frequency, target pages, target audience, priority

Toggle campaigns on/off directly from the grid.

Trigger Types

Trigger Behavior Config
Exit Intent Fires when cursor leaves viewport (top edge)
Time on Page Fires after N seconds triggerDelay
Scroll Depth Fires after X% page scroll triggerScrollDepth
Cart Abandonment Exit intent, but only when cart has items

Email Capture Event

When a visitor submits their email, the plugin dispatches:

Event: sylius_popup.email_captured
Payload: { email, popupId }

Listen to this event to integrate with Mailchimp, Sendinblue, or any email service:

use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
use Symfony\Component\EventDispatcher\GenericEvent;

#[AsEventListener(event: 'sylius_popup.email_captured')]
final class EmailCapturedListener
{
    public function __invoke(GenericEvent $event): void
    {
        $email = $event->getArgument('email');
        $popupId = $event->getArgument('popupId');

        // Send to your email marketing platform
    }
}

API Endpoint

POST /api/v2/shop/popup/{id}/subscribe
Content-Type: application/json

{ "email": "visitor@example.com" }

→ 200 { "success": true }
→ 400 { "error": "Invalid email address." }
→ 429 { "error": "Too many requests. Please try again later." }

Rate limited to 3 requests per IP per hour.

Entity: PopupCampaign

Field Type Description
name string Admin label (not shown to visitors)
enabled boolean Active/inactive toggle
title string Popup heading
body text Popup body content
ctaLabel string? CTA button text
ctaUrl string? CTA button link
discountCode string? Copyable discount code
emailCaptureEnabled boolean Show email input field
style enum modal or bar
backgroundColor string Hex color (default #ffffff)
textColor string Hex color (default #111111)
buttonColor string Hex color (default #000000)
triggerType enum exit_intent, time_on_page, scroll_depth, cart_abandonment
triggerDelay int Seconds (for time_on_page)
triggerScrollDepth int Percentage (for scroll_depth)
showFrequency enum session, day, week
targetPages enum all, product, cart, checkout
targetAudience enum everyone, guests, logged_in
priority int Higher = shown first

Architecture

src/
├── Controller/
│   ├── Admin/PopupCampaignController.php    # CRUD + AJAX toggle
│   └── Shop/PopupSubscribeController.php    # Email capture API
├── DependencyInjection/
│   ├── Configuration.php
│   └── SyliusPopupExtension.php             # Prepends resources, grids, hooks
├── Entity/
│   ├── PopupCampaign.php
│   └── PopupCampaignInterface.php
├── Enum/                                     # 5 backed string enums
├── EventListener/AdminMenuListener.php       # Marketing menu item
├── Form/Type/PopupCampaignType.php          # Admin form with all fields
├── Repository/PopupCampaignRepository.php    # Targeting query
├── Service/PopupRenderer.php                 # Page/audience resolution
├── Twig/PopupRendererExtension.php          # Twig function bridge
└── SyliusPopupPlugin.php                    # Bundle class

assets/controllers/popup-controller.js        # Stimulus controller
templates/
├── admin/popup_campaign/                     # Tabbed create/update forms
└── shop/                                     # Modal + bar + renderer

Testing

vendor/bin/phpunit

License

MIT. See LICENSE.

abderrahimghazali/sylius-popup-plugin 适用场景与选型建议

abderrahimghazali/sylius-popup-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 03 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 abderrahimghazali/sylius-popup-plugin 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-27