Download the PHP package plixus/twig-component-preview-bundle without Composer
On this page you can find all versions of the php package plixus/twig-component-preview-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download plixus/twig-component-preview-bundle
More information about plixus/twig-component-preview-bundle
Files in plixus/twig-component-preview-bundle
Package twig-component-preview-bundle
Short Description Symfony bundle for generating live preview interfaces for Twig Components with interactive forms and real-time updates
License MIT
Homepage https://github.com/plixus/twig-component-preview-bundle
Informations about the package twig-component-preview-bundle
PlixusTwigComponentPreviewBundle
A Symfony bundle that automatically generates live preview interfaces for your Twig Components. Change form values and see your components update in real-time without page reloads.
🎯 What This Bundle Does
- Automatic Form Generation: Create forms from your component properties using PHP attributes
- Live Preview: Real-time updates using Symfony Live Components - no custom JavaScript needed
- Multiple Syntax Support: Preview both
{{ component() }}and<twig:Component />syntax - Professional UI: Swiss Design inspired interface with customizable CSS variables
- Template Override: Full customization via Symfony's template override system
🚀 Installation
Requirements:
- Symfony 7.3+
- PHP 8.1+
- Symfony UX Twig Component
- Symfony UX Live Component
⚡ Quick Start (5 Minutes)
Step 1: Create Your Component
First, create a regular Twig Component and mark it for preview with attributes:
Step 2: Create the Controller
Important: You need to manually map component names to classes - the bundle doesn't auto-discover them for security reasons:
Step 3: Create the Template
Step 4: Visit Your Preview
Navigate to: https://yourdomain.com/preview/alert
That's it! You now have a live preview interface where you can:
- Change form values and see instant updates
- View component documentation
- See generated Twig code examples
- Copy-paste code snippets
📝 Component Configuration
Available Property Types
Configure your component properties with the #[PreviewProperty] attribute:
Property Attribute Options
🎨 Syntax Configuration
The bundle supports both Twig Component syntax styles. You can configure which syntax to show in the code examples:
Option 1: Configure Syntax Preference
Function Syntax (default):
HTML Syntax:
Option 2: Show Both Syntax Styles
This will display tabs showing both syntax styles so users can choose their preference.
⚙️ Advanced Configuration
Component Options
Layout Options
🎨 Template Customization
Override Bundle Templates
Create a template in your app to override the bundle's default:
Partial Template Overrides
Override specific parts by extending the original template:
🎨 CSS Customization
CSS Variables
Override CSS variables to customize the appearance:
Custom CSS Classes
Add your own styling:
🎯 Common Use Cases
1. Documentation Site
2. Design System Preview
3. Developer Testing
4. Component Library Index
Create an overview of all your components:
🔧 Troubleshooting
Common Issues
"Component not found" Error
- Make sure you've added your component to the
$componentClassesarray in your controller - Check that the component class exists and is imported
"Expected argument of type bool, null given"
- This is automatically handled by the bundle for boolean properties
- If you see this error, make sure you're using the latest version
Live updates not working
- Ensure Symfony UX Live Component is properly installed
- Check that your component properties have
#[PreviewProperty]attributes - Verify that Stimulus is loaded on your page
Styling issues
- The bundle includes its own CSS - you may need to override CSS variables
- Check that the bundle's CSS is being loaded
Bundle Requirements Check
📦 What's Next?
This bundle is perfect for:
- Design Systems: Document and preview your component library
- Development: Test components during development
- Documentation: Generate interactive component docs
- Prototyping: Quickly experiment with component variations
🤝 Contributing
Found a bug or have a feature request? Please open an issue on GitHub.
📄 License
This bundle is released under the MIT License.
All versions of twig-component-preview-bundle with dependencies
symfony/framework-bundle Version ^6.4|^7.0
symfony/twig-bundle Version ^6.4|^7.0
symfony/ux-twig-component Version ^2.8
symfony/ux-live-component Version ^2.8
symfony/stimulus-bundle Version ^2.0
symfony/asset-mapper Version ^6.4|^7.0
symfony/asset Version ^6.4|^7.0
symfony/form Version ^6.4|^7.0
symfony/validator Version ^6.4|^7.0