abenmada/sylius-broken-link-handler-plugin
Composer 安装命令:
composer require abenmada/sylius-broken-link-handler-plugin
包简介
The Broken Link Handler plugin automatically redirects outdated product and taxon slugs to their new versions, ensuring they remain permanent and preventing their reuse by other entities
README 文档
README
The Broken Link Handler plugin automatically redirects outdated product and taxon slugs to their new versions, ensuring they remain permanent and preventing their reuse by other entities.
The goal is to optimize your site so that search engines can index it more effectively, which will help improve its organic search ranking (SEO).
Presentation
Whenever you create or update a product's slug, it will be automatically saved in the product's slug history.

A slug that has already been used for a product can never be reused for another. This ensures that old slugs will always remain associated with the same product, so that when accessing an old slug, the user will be redirected to the new one.

For example, if someone tries to access the URL /fr_FR/products/000f-grey-jeans, a 301 redirect will automatically lead to /fr_FR/products/000f-v2-jean-gris.
This slug management system is also implemented for taxons. Thus, when attempting to access the page /fr_FR/taxons/t-shirts/les-hommes, a redirection will occur to /fr_FR/taxons/t-shirts/hommes.

Installation
Require plugin with composer :
composer require abenmada/sylius-broken-link-handler-plugin
Change your config/bundles.php file to add the line for the plugin :
<?php return [ //.. Abenmada\BrokenLinkHandlerPlugin\BrokenLinkHandlerPlugin::class => ['all' => true], ]
Then create the config file in config/packages/abenmada_broken_link_handler_plugin.yaml :
imports: - { resource: "@BrokenLinkHandlerPlugin/Resources/config/services.yaml" }
Copy the view responsible for displaying the taxon creation form :
mkdir -p templates/bundles/SyliusAdminBundle/Taxon cp vendor/abenmada/sylius-broken-link-handler-plugin/src/Resources/views/Admin/Taxon/_form.html.twig templates/bundles/SyliusAdminBundle/Taxon/_form.html.twig
Update the entity src/Entity/Product/Product.php :
<?php declare(strict_types=1); namespace App\Entity\Product; use Abenmada\BrokenLinkHandlerPlugin\Model\SlugHistory\ProductSlugHistoryTrait; use Abenmada\BrokenLinkHandlerPlugin\Validator\SlugExistsInOtherProductSlugHistories; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; use Sylius\Component\Core\Model\Product as BaseProduct; use Symfony\Component\Validator\Mapping\ClassMetadata; /** * @ORM\Entity * @ORM\Table(name="sylius_product") */ #[ORM\Entity] #[ORM\Table(name: 'sylius_product')] class Product extends BaseProduct { use ProductSlugHistoryTrait; public function __construct() { $this->productSlugHistories = new ArrayCollection(); parent::__construct(); } public static function loadValidatorMetadata(ClassMetadata $metadata): void { $metadata->addConstraint(new SlugExistsInOtherProductSlugHistories([ 'groups' => 'sylius', ])); } }
Update the entity src/Entity/Taxonomy/Taxon.php :
<?php declare(strict_types=1); namespace App\Entity\Taxonomy; use Abenmada\BrokenLinkHandlerPlugin\Model\SlugHistory\TaxonSlugHistoryTrait; use Abenmada\BrokenLinkHandlerPlugin\Validator\SlugExistsInOtherTaxonSlugHistories; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; use Sylius\Component\Core\Model\Taxon as BaseTaxon; use Symfony\Component\Validator\Mapping\ClassMetadata; /** * @ORM\Entity * @ORM\Table(name="sylius_taxon") */ #[ORM\Entity] #[ORM\Table(name: 'sylius_taxon')] class Taxon extends BaseTaxon { use TaxonSlugHistoryTrait; public function __construct() { $this->taxonSlugHistories = new ArrayCollection(); parent::__construct(); } public static function loadValidatorMetadata(ClassMetadata $metadata): void { $metadata->addConstraint(new SlugExistsInOtherTaxonSlugHistories([ 'groups' => 'sylius', ])); } }
Run the migration :
bin/console doctrine:migration:migrate
abenmada/sylius-broken-link-handler-plugin 适用场景与选型建议
abenmada/sylius-broken-link-handler-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 7, 最近一次更新时间为 2024 年 11 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「slug」 「e-commerce」 「sylius」 「sylius-plugin」 「permanent redirect」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 abenmada/sylius-broken-link-handler-plugin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 abenmada/sylius-broken-link-handler-plugin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 abenmada/sylius-broken-link-handler-plugin 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
TitleWithSlugInput - Easy Permalink Slugs for the FilamentPHP Form Builder (PHP / Laravel / Livewire)
Implementation of the Omnibus Directive for Sylius application.
Adds slugify twig extensions to your craft install.
The bundle for easy using json-rpc api on your project
A library to extend Object capabilities.
Livewire starter kit for Lunar e-commerce.
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-11-03