Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Slugify Bundle Laravel Package

zenstruck/slugify-bundle

Deprecated Symfony2 bundle integrating cocur/slugify. Provides a zenstruck.slugify service and optional Twig slugify filter, with configurable mode (iconv/array) and basic settings for separator and empty-value replacements.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Limited Modern Fit: The package is a Symfony2 bundle (deprecated in 2013) and targets PHP 5.x (Symfony2’s era). If the application is Symfony 5/6/7+, this bundle is not natively compatible without significant refactoring.
  • Functional Overlap: The core functionality (slug generation) is now better served by cocur/slugify, which includes a Symfony Bundle and is actively maintained.
  • Twig Integration: If the app uses Twig, the filter is a minor convenience, but modern alternatives (e.g., custom Twig extensions) are preferable.

Integration Feasibility

  • Symfony2 Only: Requires Symfony 2.x (no support for Symfony 3+). If the stack is Symfony 4+, integration would need:
    • A compatibility layer (e.g., symfony/flex or manual bundle loading).
    • Deprecation warnings due to outdated dependencies (e.g., symfony/framework-bundle:2.x).
  • Composer Conflicts: May conflict with newer Symfony autowiring or DI components.
  • Alternative Path: Easier to drop the bundle and use cocur/slugify directly with a custom service or Twig extension.

Technical Risk

  • High Risk for Modern Stacks:
    • Security: Unpatched dependencies (e.g., older Symfony versions may have CVEs).
    • Maintenance: No updates since 2013; abandoned project.
    • Breakage: Likely to fail with Symfony 5+ due to:
      • Changed service container structure.
      • Deprecated Twig/Doctrine integrations.
  • Low Risk for Legacy Systems:
    • If the app is stuck on Symfony 2.x, it may work as-is but with no future support.

Key Questions

  1. Is Symfony 2.x the only viable option?
    • If yes, proceed with caution (document deprecation risks).
    • If no, abandon this package in favor of cocur/slugify.
  2. What’s the slug generation use case?
    • For Twig templates, a custom Twig filter using cocur/slugify is simpler.
    • For services, inject cocur/slugify directly.
  3. Are there existing slug-related services/bundles?
    • Avoid duplication (e.g., stof/doctrine-extensions has slugging for entities).
  4. What’s the migration timeline?
    • If upgrading Symfony, plan to replace this bundle in the same sprint.

Integration Approach

Stack Fit

  • Symfony 2.x Only:
    • Direct Integration: Works out-of-the-box if the stack is Symfony 2.x + PHP 5.3+.
    • Dependencies:
      • cocur/slugify (v1.x, PHP 5.3+).
      • symfony/framework-bundle:2.x.
  • Symfony 3+/4+/5+/6+/7+:
    • Not Natively Supported:
      • Requires manual shimming (e.g., polyfills for deprecated Symfony 2 APIs).
      • Recommended: Use cocur/slugify (v2.x+) with a custom service or Twig extension.

Migration Path

Scenario Recommended Approach Effort
Symfony 2.x Use as-is (with deprecation warnings) Low
Symfony 3/4/5+ Replace with cocur/slugify + custom Twig Medium
Legacy PHP 5.3-5.6 Use cocur/slugify:1.x (if stuck) Low
Modern PHP 7.4+ Use cocur/slugify:2.x+ + Symfony autowire Low

Compatibility

  • Twig Filter:
    • Works in Symfony 2.x; breaks in Symfony 3+ due to Twig autoloader changes.
    • Fix: Register a custom Twig extension instead.
  • Service Injection:
    • Symfony 2.x: $this->get('zenstruck.slugify').
    • Symfony 3+: Autowire Cocur\Slugify\Slugify directly.
  • Configuration:
    • Symfony 2.x YAML config works; Symfony 3+ uses PHP/XML/YAML with different keys.

Sequencing

  1. Assess Symfony Version:
    • If Symfony 2.x, proceed with bundle (but plan replacement).
    • If Symfony 3+, skip this bundle.
  2. Replace with cocur/slugify:
    • Add to composer.json:
      "cocur/slugify": "^2.0"
      
    • Create a custom service (Symfony 3+):
      # config/services.yaml
      services:
          App\Service\SlugService:
              arguments:
                  $slugify: '@Cocur\Slugify\Slugify'
      
    • For Twig:
      // src/Twig/AppExtension.php
      class AppExtension extends \Twig\Extension\AbstractExtension
      {
          public function getFilters(): array
          {
              return [
                  new \Twig\TwigFilter('slugify', [$this->slugify, 'slugify']),
              ];
          }
      }
      
  3. Deprecate Old Code:
    • Replace zenstruck.slugify service references.
    • Update Twig templates to use |slugify (if using custom extension).

Operational Impact

Maintenance

  • Symfony 2.x:
    • High Maintenance Burden:
      • No security updates.
      • Risk of breakage with PHP 7+ (if not already upgraded).
    • Workarounds:
      • Pin cocur/slugify:1.x to avoid breaking changes.
      • Monitor for Symfony 2 EOL (scheduled for 2023).
  • Symfony 3+:
    • Zero Maintenance if replaced with cocur/slugify.
    • Active Ecosystem: cocur/slugify is updated regularly.

Support

  • No Vendor Support:
    • Original repo is archived; issues will go unanswered.
    • Alternative: Open issues in cocur/slugify for functional equivalents.
  • Community:
    • Limited Symfony 2 expertise available.
    • Modern Symfony communities can help with cocur/slugify migrations.

Scaling

  • Performance:
    • cocur/slugify is lightweight (no DB or heavy processing).
    • No scaling concerns unless generating slugs for millions of entities (then consider caching).
  • Bundle Overhead:
    • Zenstruck bundle adds minimal overhead (just a service + Twig filter).
    • Replacement (cocur/slugify) is even lighter.

Failure Modes

Risk Impact Mitigation
Symfony 2.x Deprecation App breaks on upgrade Plan replacement in upgrade sprint
PHP 7+ Incompatibility Bundle fails to load Use cocur/slugify directly
Twig Filter Breakage Twig templates fail Replace with custom extension
Dependency Conflicts Composer install fails Pin cocur/slugify version
No Security Updates Vulnerabilities in old deps Migrate to maintained package

Ramp-Up

  • For Developers:
    • Low: If using Symfony 2.x, existing code works.
    • Medium: If migrating to cocur/slugify, requires:
      • Understanding service autowiring (Symfony 3+).
      • Twig extension setup.
  • For QA:
    • Test slug generation for:
      • Edge cases (e.g., ####, Hello World).
      • Custom separators/replacements.
      • Unicode characters (if applicable).
  • For DevOps:
    • No changes if using Symfony 2.x.
    • If migrating, update composer.json and CI pipelines to test new package.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony
spatie/flare-daemon-runtime