Overview
tc-lib-file provides low-level file access and byte-reading primitives used by higher-level PDF and document libraries.
The package is intentionally small but critical: it centralizes stream safety and binary handling so dependent components can focus on document semantics instead of reimplementing I/O details.
Repository and API Docs
- GitHub: https://github.com/tecnickcom/tc-lib-file
- API docs: https://tcpdf.org/docs/srcdoc/tc-lib-file
- Packagist: https://packagist.org/packages/tecnickcom/tc-lib-file
Project Metadata
| Item | Value |
|---|---|
| Namespace | \Com\Tecnick\File |
| License | GNU LGPL v3 |
Installation
composer require tecnickcom/tc-lib-file
Where It Fits
Adopt this package when inputs may come from filesystem paths, inline data URIs, or mixed source abstractions.
Features
File Access
- Local and URL-backed file reading helpers
- Path-safety checks for local operations
- cURL-based retrieval options for remote resources
Binary Utilities
- Byte, integer, and structured binary reads
- Helpers used by parser and image/font import stacks
- Error handling through typed exceptions
Requirements
- PHP 8.2 or later
- Extensions:
curl,pcre - Composer
Development and Packaging
- QA and local checks:
make deps,make help,make qa - Packaging:
make rpm,make deb
Support and Contribution
- Sponsor: https://github.com/sponsors/tecnickcom
- Contribution guide: https://github.com/tecnickcom/tc-lib-file/blob/main/CONTRIBUTING.md
- Security policy: https://github.com/tecnickcom/tc-lib-file/blob/main/SECURITY.md
Integration Notes
- Whitelist accepted schemes and paths before loading untrusted references.
- Centralize asset resolution in one adapter to simplify auditing and testing.
- Validate MIME assumptions before embedding assets.
Example
<?php
require_once __DIR__ . '/vendor/autoload.php';
$file = new \Com\Tecnick\File\File();
$fh = $file->fopenLocal(__FILE__, 'rb');
$header = $file->fReadInt($fh);
var_dump($header);