承接 monsieurbiz/sylius-theme-companion-plugin 相关项目开发

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

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

monsieurbiz/sylius-theme-companion-plugin

Composer 安装命令:

composer require monsieurbiz/sylius-theme-companion-plugin

包简介

Use this plugin to drive your theme management.

README 文档

README

Banner of Sylius Theme Companion plugin

Theme Companion for Sylius

Theme Companion  Plugin license Tests Security Flex Recipe

A powerful companion plugin for Sylius themes with asset management, build pipelines, and package management.

Compatibility

Sylius Version PHP Version
2.0 8.2 - 8.3
1.13+ 8.2 - 8.3

ℹ️ For Sylius 1.12, see our 1.x branch and all 1.x releases.

Installation

If you want to use our recipes, you can configure your composer.json by running:

composer config --no-plugins --json extra.symfony.endpoint '["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master","flex://defaults"]'
composer require monsieurbiz/sylius-theme-companion-plugin
For the installation without flex, follow these additional steps

Change your config/bundles.php file to add this line for the plugin declaration:

<?php

return [
    //..
    MonsieurBiz\SyliusThemeCompanionPlugin\MonsieurBizSyliusThemeCompanionPlugin::class => ['all' => true],
];

Then import the routes in config/routes/monsieurbiz_sylius_theme_companion_plugin.yaml:

when@dev:
    monsieurbiz_theme_companion:
        resource: '@MonsieurBizSyliusThemeCompanionPlugin/config/routing/theme.yaml'
        prefix: /_theme

Quick Start

1. Enable Theme Companion

Add need_companion: true to your theme's composer.json:

{
  "name": "acme/my-theme",
  "type": "sylius-theme",
  "extra": {
    "sylius-theme": {
      "title": "My Awesome Theme",
      "need_companion": true
    }
  }
}

That's it! Your theme is now enhanced with Theme Companion features and will appear in the channel configuration, even if it's a packaged theme outside the themes/ folder.

💡 See it in action: Check out the naked theme example

2. Add Assets (Optional)

Place your assets in the assets/ folder in your theme:

themes/my-theme/
├── assets/
│   ├── css/
│   │   └── style.css
│   ├── js/
│   │   └── app.js
│   └── images/
│       └── logo.svg
├── templates/
└── composer.json

Assets are automatically available via Symfony Asset Mapper:

<link rel="stylesheet" href="{{ asset('@AcmeMyTheme/css/style.css') }}">
<script src="{{ asset('@AcmeMyTheme/js/app.js') }}"></script>
<img src="{{ asset('@AcmeMyTheme/images/logo.svg') }}" alt="Logo">

📁 Example: See the complete structure in naked theme

3. Configure Build Pipeline (Optional)

For SCSS, Tailwind, or other compilation needs, add a build pipeline:

{
  "extra": {
    "sylius-theme": {
      "title": "My Theme",
      "need_companion": true,
      "build_pipeline": {
        "css": {
          "input": "%theme_companion.acme_my_theme.assets_path%/styles/main.scss",
          "output": "%theme_companion.current_theme.assets_generated_path%/css/style.css",
          "runner": "sass"
        }
      }
    }
  }
}

Supported runners: sass, tailwind, copy

📦 Examples:

Commands

Debug Themes

# List all themes
php bin/console debug:theme

# Show detailed theme information
php bin/console debug:theme acme/my-theme

Install Dependencies

# Install theme dependencies (JS packages, Composer packages, etc.)
php bin/console theme:install acme/my-theme

Build Assets

# Build theme assets once
php bin/console theme:build acme/my-theme

# Watch for changes and rebuild automatically (development mode)
php bin/console theme:watch acme/my-theme

Configuration Options

Naming Convention

The name of your theme will be used in two main places:

  • Asset Mapper prefix (e.g., {{ asset('@MonsieurbizSyliusFooTheme/css/style.css') }})
  • Parameter name (e.g., %theme_companion.monsieurbiz_sylius_foo_theme.assets_path%)

If the name of your theme is monsieurbiz/sylius-foo-theme in the composer.json file:

Rule Without custom prefix With custom prefix My-Foo Theme
Asset Mapper prefix Camel case prefixed with @ @MonsieurbizSyliusFooTheme @MyFooTheme
Parameter name Snake case without @ monsieurbiz_sylius_foo_theme my_foo_theme

Custom Prefix

Control the Asset Mapper prefix:

{
  "extra": {
    "sylius-theme": {
      "title": "My Theme",
      "need_companion": true,
      "prefix": "@MyCustomPrefix"
    }
  }
}

📄 Example: naked theme

JavaScript Dependencies

Manage JS packages with Asset Mapper:

{
  "extra": {
    "sylius-theme": {
      "dependencies": {
        "js": {
          "package_file": "%theme_companion.acme_my_theme.assets_path%/package.json",
          "package_manager": "asset_mapper"
        }
      }
    }
  }
}

Then create assets/package.json containing your dependencies:

{
  "dependencies": {
    "alpinejs": "^3.0"
  }
}

📄 Example: naked theme dependencies

Theme Variables

Pass variables to Twig templates:

{
  "extra": {
    "sylius-theme": {
      "vars": {
        "twig": {
          "logo_text": "My Shop",
          "primary_color": "#ff6b6b"
        }
      }
    }
  }
}

Access in templates: {{ theme.getVar('twig', 'logo_text') }}

📄 Example: naked theme variables

Parent Themes

Inherit configuration from another theme:

{
  "extra": {
    "sylius-theme": {
      "title": "Child Theme",
      "need_companion": true,
      "parents": ["acme/base-theme"]
    }
  }
}

Child themes inherit build pipelines, dependencies, and variables from parent themes.

📄 Example: quartz theme

Asset Mapper Configuration

Add additional Asset Mapper paths or exclude patterns:

{
  "extra": {
    "sylius-theme": {
      "assets_managers": {
        "asset_mapper": {
          "paths": {
            "%kernel.project_dir%/vendor/some/package/assets": "@some-package"
          },
          "excluded_patterns": [
            "*/node_modules/*"
          ]
        }
      }
    }
  }
}

📄 Example: original theme

Build Pipeline Options

SCSS/Sass Compilation

{
  "build_pipeline": {
    "css": {
      "input": "%theme_companion.acme_my_theme.assets_path%/styles/main.scss",
      "output": "%theme_companion.current_theme.assets_generated_path%/css/style.css",
      "runner": "sass",
      "config": {
        "load_path": [
          "%kernel.project_dir%/vendor/twbs/bootstrap/scss"
        ]
      }
    }
  }
}

Tailwind CSS

{
  "build_pipeline": {
    "css": {
      "input": "%theme_companion.acme_my_theme.assets_path%/styles/main.css",
      "output": "%theme_companion.current_theme.assets_generated_path%/css/style.css",
      "runner": "tailwind",
      "config": {
        "minify": true,
        "config_file_template": "@MonsieurBizSyliusThemeCompanionPlugin/tailwind.config.js.twig"
      }
    }
  }
}

Copy Files

{
  "build_pipeline": {
    "copy_fonts": {
      "input": "%kernel.project_dir%/vendor/some/package/fonts",
      "output": "%theme_companion.current_theme.assets_generated_path%/fonts",
      "runner": "copy"
    }
  }
}

📄 Example: original theme build pipeline

Examples

Full working examples are available in the examples/themes/ directory:

  • naked - Simple theme with static CSS and Alpine.js

    • Shows basic asset structure
    • Asset Mapper integration
    • JavaScript dependencies
  • original - SCSS compilation with Asset Mapper

    • Build pipeline with Sass runner
    • JavaScript dependencies
    • Font file copying
  • quartz - Theme inheritance

    • Parent theme example
    • Shows configuration merging
    • SCSS variables override
  • naked-override - Template overriding

    • Minimal override example
    • Child theme pattern
  • packaged - Theme as Composer package

    • Distribution example
    • Shows package-based themes

Development Tools

Theme Switcher (Dev Mode Only)

Quickly switch themes during development without modifying the database:

http://localhost/_theme/switch?theme=acme/my-theme

This is only available in development mode and requires the dev routes to be imported.

Debug Toolbar

View current theme information in the Symfony profiler toolbar. The toolbar shows:

  • Active theme name
  • Theme prefix
  • Parent themes
  • Build pipeline status

Contributing

We welcome contributions! Please see our contribution guidelines for details.

License

This plugin is under the MIT license. See the LICENSE file for details.

Credits

Developed by Monsieur Biz, expert Sylius agency.

monsieurbiz/sylius-theme-companion-plugin 适用场景与选型建议

monsieurbiz/sylius-theme-companion-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 884 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 08 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-08