PHPackages                             krisell/laravel-translation-json-cache - 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. krisell/laravel-translation-json-cache

ActiveLibrary[Caching](/categories/caching)

krisell/laravel-translation-json-cache
======================================

Caches translation JSON files for faster access.

v2.0.0(6y ago)23.8k↓47.2%MITPHPCI failing

Since Oct 8Pushed 6y ago1 watchersCompare

[ Source](https://github.com/Krisell/laravel-translation-json-cache)[ Packagist](https://packagist.org/packages/krisell/laravel-translation-json-cache)[ RSS](/packages/krisell-laravel-translation-json-cache/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (5)Dependencies (2)Versions (5)Used By (0)

Laravel Translation Json Cache
==============================

[](#laravel-translation-json-cache)

When using the `.json` option for translations, the json-file is read and parsed for every request. This package provides an artisan command to cache the parsed data as a php-file, pretty much the same was as routes and configs can be cached. This gives a performance boost since no JSON-parsing has to be done and the opcache can be used. The actual performance boost depends on the size of the translation file and the disk speed, see below.

Installation
------------

[](#installation)

```
composer require krisell/laravel-translation-json-cache
```

The package is auto-registered.

Usage
-----

[](#usage)

To cache all translation JSON-files (in resources/lang), run the following artisan command:

```
php artisan translation-json:cache
```

If your json-files change, you need to run the command again for the changes to take effect.

You may also clear the cached files using the following command

```
php artisan translation-json:clear

```

Run `translation-json:cache` during deployment in the same way you run `route:cache` and `config:cache`.

The cached files are stored in the `bootstrap/cache` directory and are named `translation-{$locale}.php`.

Performance boost
-----------------

[](#performance-boost)

On a Macbook Pro 2018 (2.6 GHz i7), using Laravel Valet, and having a JSON translation file of 1500 strings (real strings of varying length), the first call to `__("A")` during a request takes about `1.2 ms`. Enabling this package and the same call takes `0.08 ms`, i.e. the actual performance boost is in the order of `1 ms`, which is substantial considering that a simple full request could be as fast as `10 ms`.

I have been using this solution in production for a while (1500 strings for each language) and I have to say the performance boost is not really noticable there (comparing CPU graphs, which of course depends on a lot of other changes as well). The difference may be smaller since our server setup uses docker and an all in-memory disk. Please feel free to contribute with additional measurements under other circumstances or with other sizes of the JSON files.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Future work
-----------

[](#future-work)

I realize the JSON-option may not be the preferred one, and that most people already use php-files for storing their translation data hierachically. In that case, a similar approach could still possibly save time on parsing and traversal, but this is outside the scope of this package. Feel free to investigate this idéa further in a new package!

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

2452d ago

Major Versions

v1.1.1 → v2.0.02019-10-10

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25909128?v=4)[Martin Sandström Krisell](/maintainers/Krisell)[@Krisell](https://github.com/Krisell)

---

Top Contributors

[![Krisell](https://avatars.githubusercontent.com/u/25909128?v=4)](https://github.com/Krisell "Krisell (22 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/krisell-laravel-translation-json-cache/health.svg)

```
[![Health](https://phpackages.com/badges/krisell-laravel-translation-json-cache/health.svg)](https://phpackages.com/packages/krisell-laravel-translation-json-cache)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
