scaleflex/sylius-filerobot-plugin
Composer 安装命令:
composer require scaleflex/sylius-filerobot-plugin
包简介
Acme example plugin for Sylius.
README 文档
README
Step 1: Download the plugin
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
composer require scaleflex/sylius-filerobot-plugin
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Enable the plugin
Then, enable the plugin by adding it to the list of registered plugins/bundles in config/bundles.php file of your project:
<?php
# config/bundles.php
return [
// ...
Scaleflex\SyliusFilerobotPlugin\ScaleflexSyliusFilerobotPlugin::class => ['all' => true],
];
Step 3: Configure the plugin
Update DB Schema
bin/console doctrine:migration:diff bin/console doctrine:migration:migrate bin/console cache:clear
Add Admin route
Create file in config/routes/scaleflex_sylius_filerobot.yaml and add content bellow
# config/routes/scaleflex_sylius_filerobot.yaml scaleflex_sylius_filerobot: resource: "@ScaleflexSyliusFilerobotPlugin/Resources/config/routing.yaml"
Update product media tab form
Change form theme {% form_theme form '@ScaleflexSyliusFilerobotPlugin/Admin/Form/imagesTheme.html.twig' %}
in your templates/bundles/SyliusAdminBundle/Product/Tab/_media.html.twig
{% form_theme form '@ScaleflexSyliusFilerobotPlugin/Admin/Form/imagesTheme.html.twig' %}
<div class="ui tab" data-tab="media">
<h3 class="ui top attached header">{{ 'sylius.ui.media'|trans }}</h3>
<div class="ui attached segment">
{{ form_row(form.images, {'label': false}) }}
{{ sylius_template_event(['sylius.admin.product.' ~ action ~ '.tab_media', 'sylius.admin.product.tab_media'], {'form': form}) }}
</div>
</div>
Update product grid thumbnail
Change grid thumbnail column template
# config/package/_sylius.yaml sylius_grid: grids: sylius_admin_product: fields: image: options: template: "@ScaleflexSyliusFilerobotPlugin/Admin/Product/Grid/Field/image.html.twig"
Add script
# config/package/sylius_ui.yaml sylius_ui: events: sylius.admin.layout.javascripts: blocks: filerobot_script: '@ScaleflexSyliusFilerobotPlugin\Admin\filerobotScript.html.twig'
Add config filter
Create a file config/packages/scaleflex_filerobot.yaml and add content bellow
imports: - { resource: "@ScaleflexSyliusFilerobotPlugin/Resources/config/filters.yaml"}
Update config in Admin
Goto Scaleflex Filerobot under Configuration

You can only enable if token, security template id are correct
- Activation: Enable/Disable Filerobot plugin
- Filerobot Token: Your Filerobot token
- Security Template Identifier: Your security template ID
- Filerobot upload directory: Folder path to your asset, ie /magento
Developer guide
The Filerobot plugin provide some twig method, filter support developer
-
is_filerobot(image_path): Twig function check if image is filerobot -
image_path|filerobot('sylius_shop_product_thumbnail'): Twig Filter, with image size, you can add more filter inconfig/package/scaleflex_filerobot.yamlscaleflex_sylius_filerobot: filters: custom_size: { width: 120, height: 120 }
and in Twig
image_path|filerobot('custom_size')We have some default size follow Sylius default, you can override it in filter config above
scaleflex_sylius_filerobot: filters: sylius_admin_product_large_thumbnail: { width: 550, height: 412 } sylius_admin_product_small_thumbnail: { width: 150, height: 112 } sylius_admin_product_tiny_thumbnail: { width: 64, height: 64 } sylius_admin_product_thumbnail: { width: 50, height: 50 } sylius_shop_product_tiny_thumbnail: { width: 64, height: 64 } sylius_shop_product_small_thumbnail: { width: 150, height: 112 } sylius_shop_product_thumbnail: { width: 260, height: 260 } sylius_shop_product_large_thumbnail: { width: 550, height: 412 } sylius_small: { width: 120, height: 120 }
-
If you use Scaleflex Filerobot on existing File you have to check the path is filerobot or not, if not use the default way
Example with Sylius default
templates/bundles/SyliusShopBundle/Product/_mainImage.html.twig
{% if product.imagesByType('thumbnail') is not empty %}
{% if is_filerobot(product.imagesByType('thumbnail').first.path) %}
{% set path = product.imagesByType('thumbnail').first.path|filerobot('sylius_shop_product_thumbnail') %}
{% else %}
{% set path = product.imagesByType('thumbnail').first.path|imagine_filter(filter|default('sylius_shop_product_thumbnail')) %}
{% endif %}
{% elseif product.images.first %}
{% if is_filerobot(product.images.first.path) %}
{% set path = product.images.first.path|filerobot('sylius_shop_product_thumbnail') %}
{% else %}
{% set path = product.images.first.path|imagine_filter(filter|default('sylius_shop_product_thumbnail')) %}
{% endif %}
{% else %}
{% set path = asset('assets/shop/img/200x200.png') %}
{% endif %}
<img src="{{ path }}" {{ sylius_test_html_attribute('main-image') }} alt="{{ product.name }}" class="ui bordered image" />
templates/bundles/SyliusShopBundle/Product/Show/_mainImage.html.twig
{% if product.imagesByType('main') is not empty %}
{% set source_path = product.imagesByType('main').first.path %}
{% if not is_filerobot(source_path) %}
{% set original_path = source_path|imagine_filter('sylius_shop_product_original') %}
{% set path = source_path|imagine_filter(filter|default('sylius_shop_product_large_thumbnail')) %}
{% else %}
{% set original_path = source_path|filerobot('sylius_shop_product_original') %}
{% set path = source_path|filerobot('sylius_shop_product_large_thumbnail') %}
{% endif %}
{% elseif product.images.first %}
{% set source_path = product.images.first.path %}
{% if not is_filerobot(source_path) %}
{% set original_path = source_path|imagine_filter('sylius_shop_product_original') %}
{% set path = source_path|imagine_filter(filter|default('sylius_shop_product_large_thumbnail')) %}
{% else %}
{% set original_path = source_path|filerobot('sylius_shop_product_original') %}
{% set path = source_path|filerobot('sylius_shop_product_large_thumbnail') %}
{% endif %}
{% else %}
{% set original_path = asset('assets/shop/img/400x300.png') %}
{% set path = original_path %}
{% endif %}
<div data-product-image="{{ path }}" data-product-link="{{ original_path }}"></div>
<a href="{{ original_path }}" class="ui fluid image" data-lightbox="sylius-product-image">
<img src="{{ path }}" id="main-image" alt="{{ product.name }}" {{ sylius_test_html_attribute('main-image') }} />
</a>
{% if product.images|length > 1 %}
<div class="ui divider"></div>
{{ sylius_template_event('sylius.shop.product.show.before_thumbnails', {'product': product}) }}
<div class="ui small images">
{% for image in product.images %}
{% set path = image.path is not null ? (is_filerobot(image.path) ? image.path|filerobot('sylius_shop_product_small_thumbnail') : image.path|imagine_filter('sylius_shop_product_small_thumbnail')) : asset('assets/shop/img/200x200.png') %}
<div class="ui image">
{% if product.isConfigurable() and product.enabledVariants|length > 0 %}
{% include '@SyliusShop/Product/Show/_imageVariants.html.twig' %}
{% endif %}
<a href="{{ is_filerobot(image.path) ? image.path|filerobot('sylius_shop_product_original') : image.path|imagine_filter('sylius_shop_product_original') }}" data-lightbox="sylius-product-image">
<img src="{{ path }}" data-large-thumbnail="{{ is_filerobot(image.path) ? image.path|filerobot('sylius_shop_product_large_thumbnail') : image.path|imagine_filter('sylius_shop_product_large_thumbnail') }}" alt="{{ product.name }}" />
</a>
</div>
{% endfor %}
</div>
{% endif %}
scaleflex/sylius-filerobot-plugin 适用场景与选型建议
scaleflex/sylius-filerobot-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 05 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「sylius」 「sylius-plugin」 「scaleflex」 「filerobot」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 scaleflex/sylius-filerobot-plugin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 scaleflex/sylius-filerobot-plugin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 scaleflex/sylius-filerobot-plugin 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Implementation of the Omnibus Directive for Sylius application.
Bulk export of sylius resources
Sylius plugin that integrates Addwish
Setono example plugin for Sylius.
Will translate fragments of text automatically
Use price tiers in your Sylius store.
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-05-10