Download the PHP package fitzage/optimus-bard without Composer
On this page you can find all versions of the php package fitzage/optimus-bard. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fitzage/optimus-bard
More information about fitzage/optimus-bard
Files in fitzage/optimus-bard
Package optimus-bard
Short Description Optimus Bard takes the content from a Statamic Bard field and transforms it into a string when updating your search index
License MIT
Informations about the package optimus-bard
Optimus Bard v2.0
Advanced search transformer for Statamic Bard fields with deep content extraction and Statamic 5 support
✨ What's New in v2.0
- Statamic 5 Support: Fully compatible with Statamic 5 and Laravel 11+
- Deep Content Extraction: Recursively extracts content from nested Bard fields and complex sets
- Enhanced Set Processing: Automatically detects and extracts content from all text-bearing fields within sets
- Improved Error Handling: Graceful fallbacks for malformed content or missing blueprints
- Modern PHP: Requires PHP 8.2+ with modern Laravel helpers
Features
What this addon does:
- Deep Content Extraction: Processes not just top-level Bard text blocks, but also recursively extracts content from:
- Nested Bard fields within sets
- Text fields, textareas, and markdown fields within component sets
- Title, description, and content fields in complex page builders
- Smart Set Processing: Automatically identifies content-bearing fields without requiring manual configuration
- Backward Compatibility: Maintains compatibility with existing v1.x configurations
- Configurable Depth: Prevents infinite recursion with configurable extraction depth limits
- Enhanced Cleanup: Improved text cleaning and normalization for better search results
Requirements
- PHP ^8.2
- Statamic ^5.0
- Laravel ^11.0
Installation
You can search for this addon in the Tools > Addons
section of the Statamic control panel and click install, or run the following command from your project root:
Basic Usage
Configure your search indexes using the Statamic search documentation.
In config/statamic/search.php
, add the following at the top of the file, below the <?php
line:
Simple Configuration
For basic Bard fields with standard content:
Advanced Configuration
For complex page builders with nested content:
Configuration Options
Parameters
- $bard (required): The Bard field content
- $blueprintPath (required): Path to the blueprint (e.g.,
collections/pages/page
) - $fieldName (required): Name of the field in the blueprint
- $userSetTypes (optional): Array of additional set types to specifically include
- $options (optional): Configuration array with the following options:
max_depth
(default: 3): Maximum recursion depth for nested contentmax_length
(default: 90000): Maximum length of the output string
Automatic Content Detection
The transformer automatically detects and extracts content from:
- Standard Bard text blocks
- Nested Bard fields within sets
- Common content field types:
text
,textarea
,markdown
,title
,description
,content
,heading
,body
- Complex component structures (hero sections, testimonials, features, etc.)
Complete Example
Here's a complete search configuration for a modern Statamic site with complex content structures:
Migrating from v1.x
The v2.0 API is backward compatible with v1.x usage. Your existing transformers will continue to work:
Error Handling
The transformer includes robust error handling:
- Missing Blueprints: Falls back to raw content processing if blueprint is not found
- Malformed Content: Gracefully handles unexpected data structures
- Recursion Protection: Prevents infinite loops with depth limiting
- Memory Management: Configurable content length limits
Performance Considerations
- Recursion Depth: Set appropriate
max_depth
based on your content structure - Content Length: Use
max_length
to prevent oversized search indexes - Caching: Consider implementing application-level caching for large content volumes
Troubleshooting
Content Not Being Extracted
- Check that the blueprint path and field name are correct
- Verify that your content structure contains text-bearing fields
- Increase
max_depth
if you have deeply nested content - Add specific set types to the
$userSetTypes
parameter
Performance Issues
- Reduce
max_depth
to limit recursion - Set a lower
max_length
value - Consider excluding certain set types if they don't contain relevant content
Changelog
v2.0.0
- Added Statamic 5 support
- Implemented deep content extraction
- Added configurable options
- Improved error handling
- Modern PHP 8.2+ requirements
v1.x
- Original Statamic 3 support
- Basic Bard field transformation
Acknowledgements
Special thanks to Erin Dalzell for the original inspiration and guidance.