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

Twigcn Bundle Laravel Package

ducrot/twigcn-bundle

TwigcnBundle brings shadcn/ui-inspired, accessible UI components to Symfony & Twig. Install the PHP bundle plus the @ducrot/twigcn-ui NPM package and compile Tailwind CSS to use ready-made, themeable components in your templates.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Symfony/Twig Alignment: The bundle is tightly integrated with Symfony 7.x+ and leverages Twig’s TwigComponent system, making it a natural fit for Symfony-based applications. The architecture follows Symfony’s component-based UI pattern, aligning with modern Symfony UX practices.
  • Tailwind CSS Dependency: Requires Tailwind CSS 4.0+, which is a blocker for non-Tailwind projects but a force multiplier for teams already using Tailwind. The bundle’s styling is highly opinionated (shadcn/ui-inspired), which may limit customization for projects with divergent design systems.
  • Stimulus Integration: Uses Symfony UX Stimulus for interactive components (e.g., dialogs, drawers), which is standard in Symfony 7.x but may require migration effort for projects using custom Stimulus setups or Webpack Encore.
  • Asset Pipeline: Relies on AssetMapper (Symfony 7.x default) or Vite/Webpack Encore, which is compatible with modern Symfony but adds complexity for legacy setups.

Integration Feasibility

  • Low-Coupling Design: The bundle does not modify core Symfony and plays well with existing templates, forms, and controllers. Components are self-contained (e.g., <twig:Twigcn:Button>) and can be adopted incrementally.
  • Form Integration: Supports Symfony’s form system via components like FieldForm, Input, and Checkbox, reducing boilerplate for form rendering.
  • Theming Flexibility: CSS custom properties (--primary, --radius) allow thematic customization, but heavy overrides may require deep Tailwind knowledge.
  • Accessibility: Components are ARIA-compliant by design, reducing risk of accessibility regressions.

Technical Risk

  • Tailwind CSS Lock-in: Projects not using Tailwind will need to adopt it or fork the bundle to replace Tailwind-specific styles (e.g., btn-primary classes). Risk: High for non-Tailwind teams.
  • Stimulus Dependency: Interactive components (e.g., Dialog, Drawer) require Stimulus 2.x+ and Symfony UX. Projects using Stimulus 1.x or custom setups will need migration effort. Risk: Medium.
  • Asset Pipeline Complexity: AssetMapper/Vite/Webpack Encore configurations are non-trivial for teams unfamiliar with modern asset pipelines. Risk: Medium.
  • Component Maturity: With 0 stars/dependents, the bundle lacks community validation. Risk: Low (MIT license mitigates risk, but lack of adoption is a red flag).
  • PHP 8.2+ Requirement: May block legacy projects still on PHP 8.1 or lower. Risk: Low-Medium (depends on project constraints).

Key Questions

  1. Design System Compatibility:

    • Does the project’s design system align with shadcn/ui’s aesthetic? If not, how will theming be customized?
    • Are there existing Tailwind CSS classes in the project that could conflict with the bundle’s styles?
  2. Asset Pipeline Readiness:

    • Is the project using AssetMapper, Vite, or Webpack Encore? If not, what’s the migration path?
    • Who will maintain the Tailwind CSS build process (e.g., npx tailwindcss --watch)?
  3. Stimulus Adoption:

    • Is Symfony UX Stimulus already in use? If not, what’s the effort to adopt it?
    • Are there custom Stimulus controllers that could conflict with the bundle’s controllers?
  4. Form System Impact:

    • How will the bundle’s form components (FieldForm, Input) interact with existing Symfony forms (e.g., {{ form_widget() }})?
    • Are there plans to replace all form rendering with Twigcn components?
  5. Performance:

    • What’s the impact of adding ~50+ interactive components on bundle size and client-side performance?
    • Are there plans to lazy-load components or use critical CSS?
  6. Long-Term Maintenance:

    • Who will handle updates if the bundle gains traction? (Issues/PRs are directed to the monorepo.)
    • Is there a rollback plan if the bundle introduces breaking changes?
  7. Testing:

    • How will components be tested (e.g., Stimulus behaviors, accessibility)?
    • Are there existing tests for the bundle’s Twig templates?

Integration Approach

Stack Fit

  • Symfony 7.x+: Native fit due to AssetMapper, Symfony UX, and TwigComponent support.
  • Symfony 6.x: Possible but unsupported; requires manual Stimulus/AssetMapper workarounds.
  • Legacy Symfony: Not recommended without significant refactoring (PHP 8.2+, Tailwind 4+, Stimulus 2+).
  • Non-Symfony Twig: Not applicable; bundle is Symfony-specific.

Migration Path

  1. Assessment Phase:

    • Audit existing UI components (e.g., buttons, forms) to identify candidates for replacement.
    • Verify Tailwind CSS compatibility (or plan for migration).
    • Check Stimulus usage (upgrade if needed).
  2. Pilot Integration:

    • Start with non-critical components (e.g., buttons, alerts) in a single template.
    • Test form integration with FieldForm and Input components.
    • Validate Stimulus interactions (e.g., dialogs, drawers) in a staging environment.
  3. Full Adoption:

    • Replace legacy UI components incrementally (e.g., one feature per sprint).
    • Migrate asset pipelines (Tailwind CLI → Vite/Webpack Encore if desired).
    • Update theming to align with the bundle’s CSS variables.
  4. Rollback Plan:

    • Maintain a feature flag for Twigcn components during migration.
    • Document custom overrides for components that don’t fit the design system.

Compatibility

Feature Compatibility Notes
Symfony Forms Works with FieldForm, Input, Checkbox, etc., but may require form theme updates.
Symfony UX Full support for Stimulus controllers (Symfony UX TwigComponent).
Webpack Encore Supported but requires manual Stimulus registration.
Vite Recommended for modern setups (via pentatrion/vite-bundle).
AssetMapper Native support; minimal configuration needed.
Dark Mode Built-in via ThemeSwitcher or manual dark class toggling.
Custom Theming Possible via CSS variables, but heavy customization may require forking.

Sequencing

  1. Prerequisites:

    • Upgrade to PHP 8.2+, Symfony 7.0+, and Tailwind CSS 4.0+.
    • Install Node.js 22+ and set up the asset pipeline (Tailwind CLI or Vite).
  2. Core Setup:

    • Install the bundle (composer require ducrot/twigcn-bundle).
    • Add @ducrot/twigcn-ui to node_modules and configure importmap or Vite.
  3. Styling:

    • Configure tailwind.css with @source directives for bundle/templates.
    • Build Tailwind assets (npx tailwindcss --watch).
  4. Stimulus:

    • Register controllers via controllers.json (Symfony UX) or bootstrap.js (manual).
  5. Component Adoption:

    • Replace buttons, forms, and alerts first (low risk).
    • Gradually adopt interactive components (e.g., dialogs, drawers).
    • Test edge cases (e.g., nested components, form submissions).
  6. Optimization:

    • Audit unused components to reduce bundle size.
    • Implement lazy-loading for non-critical components (e.g., toasters).

Operational Impact

Maintenance

  • Bundle Updates:
    • Updates will come from the monorepo (ducrot/twigcn), requiring coordination with the upstream project.
    • Dependency risk: Tailwind CSS, Stimulus, and Symfony updates may introduce breaking changes.
  • Asset Pipeline:
    • Tailwind CLI or Vite builds must be monitored for failures (e.g., missing @source paths).
    • CI/CD integration needed for automated builds (e.g., GitHub Actions).
  • Theming:
    • CSS custom properties (:root) must be documented for future developers.
    • Overrides to bundle styles may break on updates (forking may be necessary).

Support

  • Debugging:
    • Stimulus controller issues may require deep inspection of controllers.json or bootstrap.js.
    • Tailwind build errors often stem from incorrect @source paths in tailwind.css.
    • Twig template errors may arise from malformed component usage (e.g., missing required attributes).
  • Community:
    • No active community (0 stars/dependents); support relies on the mon
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.
craftcms/url-validator
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