Download the PHP package vasilgerginski/filamentphp-text-extractor without Composer
On this page you can find all versions of the php package vasilgerginski/filamentphp-text-extractor. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vasilgerginski/filamentphp-text-extractor
More information about vasilgerginski/filamentphp-text-extractor
Files in vasilgerginski/filamentphp-text-extractor
Package filamentphp-text-extractor
Short Description Extract and manage translatable text from Filament models with an intuitive admin interface
License MIT
Informations about the package filamentphp-text-extractor
Filament Text Extractor
A powerful Laravel package that seamlessly integrates with Filament Admin Panel to extract and manage translatable text from your Eloquent models. Perfect for multi-language applications, content management systems, and any project requiring dynamic text extraction and translation management.
๐ Features
๐ Automatic Text Extraction
- Extract translatable fields from any Eloquent model with a simple trait
- Auto-generate Laravel translation files in standard format (
lang/en/model_name.php
) - Support for simple text fields, JSON structures, and rich content
โจ Translation Casts (NEW!)
- Translatable Cast: Use
{{ $post->title }}
instead of{{ __('blog_post.' . $post->title) }}
- JsonTranslatable Cast: Automatic translation for JSON UI components (hero sections, feature grids, etc.)
- Zero code changes required in your templates!
๐จ Filament Integration
- Beautiful admin interface built with Filament for managing extracted texts
- Filament Plugin Architecture: Automatically registers with your admin panel
- Built-in resource for managing translations
๐๏ธ Advanced Content Support
- Rich Text Support: Extracts text from HTML, Markdown, and rich text editor content
- JSON Field Translation: Perfect for page builders, CMS blocks, and UI components
- Nested Structure Support: Works recursively through complex JSON data
๐ Multi-Language Ready
- Built-in support for multiple languages and locales
- Laravel Standard: Uses Laravel's translation system (
__()
helper) - Smart Fallbacks: Returns original text if no translation found
โก Performance & Developer Experience
- Queue Support: Handle bulk text extraction asynchronously
- Live Demos: Comprehensive examples showing all features
- Well Tested: Comprehensive test suite included
- Easy Installation: Simple setup with minimal configuration
๐ Requirements
- PHP 8.1 or higher
- Laravel 10.0 or higher
- Filament 3.0 or higher
๐ง Installation
Install the package via Composer:
Register the plugin in your Panel provider (e.g., app/Providers/Filament/AdminPanelProvider.php
):
Publish and run the migrations:
Optionally, publish the config file:
๐ฏ Quick Start
1. Add the Trait to Your Model
Add the ExtractsTranslatableText
trait to any model you want to extract text from:
2. Extract Text
You can extract text from a single model instance:
Or extract from all instances of a model:
3. Use the Artisan Command
Extract text for any model using the provided Artisan command:
โจ Translation Casts (NEW!)
๐ฏ Translatable Cast for Simple Fields
Instead of manual translation calls, use the Translatable
cast for automatic translation:
Usage in templates:
๐๏ธ JsonTranslatable Cast for UI Components
Perfect for page builders, CMS content blocks, and JSON-based UI components:
JSON Structure (stored in database):
Template Usage (no translation calls needed!):
Translation Results:
- English: "Welcome to Our Platform"
- Spanish: "Bienvenido a Nuestra Plataforma" (automatic!)
๐ง Smart Field Detection
The JsonTranslatable
cast automatically detects and translates:
- โ
UI Text:
title
,subtitle
,heading
,description
,label
,button_text
- โ Technical Data:
type
,icon
,url
,id
,background_image
(ignored)
๐ญ Live Demos & Examples
Check out the examples/
directory for comprehensive demos:
- ๐ Translation Demo: Classic
__()
approach - โจ Cast Demo: Automatic
{{ $property }}
translation - ๐๏ธ JSON Demo: UI component translation with JsonTranslatable cast
- ๐ CLI Demo: Command-line testing and statistics
Quick demo setup:
๐ Advanced Features
Filament Builder Block Extraction
The package automatically detects and extracts text from Filament Builder JSON blocks. When you have a Builder field with blocks like:
The extractor will automatically:
- Parse the JSON structure
- Extract text from all text-based fields within blocks
- Maintain context with keys like
model.field.block_type.field_name
- Skip non-text fields like images (but extract alt text!)
Rich Text Extraction
For rich text fields (TinyMCE, Trix, etc.), the package:
- Strips HTML tags to extract clean text
- Preserves meaningful content structure
- Handles nested HTML elements
- Extracts alt text from images
- Processes both plain HTML and encoded content
Example:
๐จ Filament Admin Interface
The package automatically registers a Filament resource for managing extracted texts. After installation, you'll find a new "Extracted Texts" section in your Filament admin panel with:
- List View: Browse all extracted texts with search and filters
- Edit View: Update extracted text content and metadata
- Create View: Manually add new text entries
- Dashboard: Overview of extraction statistics and recent activity
Dashboard Features
The extraction dashboard provides:
- Total number of extracted texts
- Breakdown by model type
- Language distribution
- Recent extractions
- Quick actions for bulk operations
โ๏ธ Configuration
The configuration file (config/filament-text-extractor.php
) allows you to customize:
๐ Field Handlers
The package includes specialized handlers for different field types:
- EmailHandler: Validates and formats email fields
- UrlHandler: Handles URL validation and formatting
- RichTextHandler: Processes HTML/rich text content, strips tags and extracts clean text
- SlugHandler: Manages URL slugs
- LongTextHandler: Optimized for large text fields
- Built-in JSON Support: Automatically detects and extracts text from Filament Builder blocks and other JSON structures
Creating Custom Field Handlers
You can create custom field handlers by extending the AbstractFieldHandler
:
๐ Auto-Generated Translation Files
The package can automatically generate Laravel translation files in your lang
directory, enabling seamless localization:
Automatic Translation File Generation
When texts are extracted, the package automatically creates/updates translation files:
Using Translations in Your Models
With the generated translation files, you can easily access localized content:
Automatic Model Casting
You can even create a custom cast for automatic translation:
Translation Workflow
- Extract: Run extraction to populate the database and generate translation files
- Translate: Edit the generated files in
lang/[locale]/
or use the Filament admin - Deploy: Your application automatically uses the translated values
๐งช Testing
The package includes a comprehensive test suite. Run the tests with:
For code coverage:
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
๐ Bug Reports
If you discover any issues, please create an issue on GitHub: https://github.com/vasilGerginski/filamentphp-text-extractor/issues
๐ Changelog
Please see CHANGELOG for more information on what has changed recently.
๐ Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
๐ Credits
- Vasil Gerginski
- All Contributors
๐ License
The MIT License (MIT). Please see License File for more information.
๐ Show Your Support
If you find this package helpful, please consider giving it a star on GitHub! โญ
Built with โค๏ธ by Vasil Gerginski
All versions of filamentphp-text-extractor with dependencies
laravel/framework Version ^10.0|^11.0|^12.0
filament/filament Version ^3.0
illuminate/support Version ^10.0|^11.0|^12.0
illuminate/database Version ^10.0|^11.0|^12.0