PHPackages                             larsgmortensen/litetxt - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. larsgmortensen/litetxt

ActiveLibrary[Caching](/categories/caching)

larsgmortensen/litetxt
======================

Lightweight static text manager for PHP with in-memory caching, file-based storage, and optional logging.

v1.0.0(7mo ago)0101GPL-3.0-or-laterPHPPHP &gt;=7.4

Since Sep 19Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/LarsGMortensen/LiteTxt)[ Packagist](https://packagist.org/packages/larsgmortensen/litetxt)[ Docs](https://github.com/LarsGMortensen/LiteTxt)[ RSS](/packages/larsgmortensen-litetxt/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (1)

LiteTxt – A Lightweight &amp; High-Performance Static Text Manager for PHP
==========================================================================

[](#litetxt--a-lightweight--high-performance-static-text-manager-for-php)

LiteTxt is a **fast, minimal, single-file** utility for **loading static texts** (labels, messages, i18n) from **PHP array files** with **in-memory caching** and **optional JSON logging**. It focuses on **robustness**, **low overhead**, and **predictable performance** - with **zero dependencies** (**PHP 7.4+**).

---

🚀 Features that make LiteTxt stand out
--------------------------------------

[](#-features-that-make-litetxt-stand-out)

- **Blazing-fast lookups** – Single include per file per request; subsequent reads are served from memory.
- **Zero deps, tiny API** – One class, static methods; PSR-4 autoloadable.
- **Optional structured logging** – JSON log lines for **invalid files** (ERROR) and **missing/null/empty keys** (WARNING).
- **Strict typing &amp; defensive casting** – Always returns `string`; scalars are safely cast; non-scalars fall back to default + warning.
- **Cache control** – `clearCache()` for tests and long-running processes.
- **Production-ready** – Verified by functional tests and browser-based competitor benchmarks.

---

📦 Installation
--------------

[](#-installation)

Via Composer (recommended):

```
composer require larsgmortensen/litetxt
```

Or include the class manually (PSR-4):

```
use LiteTxt\LiteTxt;
require_once __DIR__.'/src/LiteTxt/LiteTxt.php';
```

**PHP 7.4+** is required (typed properties). Benchmarks in the repo were run on PHP 8.2 with OPcache enabled.

---

🚀 Quick Start
-------------

[](#-quick-start)

### 1) Define your texts in PHP files

[](#1-define-your-texts-in-php-files)

`texts/en.php`

```
