alirashidnahal / polytext
Framework-agnostic PHP library for parsing, reading, and writing text across many file formats.
v2.0.1
2026-11-11 09:11 UTC
Requires
- php: ^8.3
- ext-dom: *
- ext-fileinfo: *
- ext-json: *
- ext-libxml: *
- ext-mbstring: *
- ext-zip: *
- dompdf/dompdf: ^3.1
- league/csv: ^9.27
- phpoffice/phpspreadsheet: ^5.10
- phpoffice/phpword: ^1.4.0
- smalot/pdfparser: ^2.13
- symfony/yaml: ^7.2|^8.0
Requires (Dev)
- illuminate/support: ^13.0
- laravel/pint: ^1.32
- phpoffice/phppresentation: dev-master as 1.3.0
- phpstan/phpstan: ^2.3
- phpstan/phpstan-phpunit: ^2.1
- phpunit/phpunit: ^12.0
Suggests
- illuminate/support: Required for the optional Laravel bridge (^13.0).
- phpoffice/phppresentation: Required for PPT/PPTX. Stable 1.2.0 conflicts with PhpSpreadsheet 5; until 1.3.0 is tagged, use: composer require phpoffice/phppresentation:dev-master
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-15 23:13:05 UTC
README
Framework-agnostic PHP library for parsing, reading, and writing text across many file formats.
Requirements
- PHP 8.3+
- Extensions:
dom,fileinfo,json,mbstring,zip - PhpSpreadsheet 5.10+ (4.x is rejected by Composer security advisories)
Installation
composer require alirashidnahal/polytext
PPT/PPTX need phpoffice/phppresentation. The latest stable release (1.2.0) cannot be installed next to PhpSpreadsheet 5. Until PHPPresentation 1.3.0 is tagged, add it only if you need those formats:
composer require phpoffice/phppresentation:dev-master
Quick Start
use Alirashidnahal\Polytext\Polytext; $polytext = new Polytext(); $document = $polytext->open('report.docx'); foreach ($document->nodes() as $node) { $node->setText(strtoupper($node->text())); } $document->save('report-modified.docx');
Supported Formats
| Category | Extensions |
|---|---|
| Text | txt, text, log, md, markdown |
| Subtitles | srt, vtt, ass, ssa, sub |
| Web | html, htm, xml |
| Data | json, csv, yaml, yml |
| Office | docx, odt, rtf, xlsx, xls, ods, pptx, ppt |
Laravel
Auto-discovery registers PolytextServiceProvider and the Polytext facade.
use Alirashidnahal\Polytext\Laravel\Facades\Polytext; $document = Polytext::open(storage_path('app/file.docx'));
Publish config:
php artisan vendor:publish --tag=polytext-config
Development
composer install
composer test
composer analyse
composer format
License
MIT © Ali Rashidnahal