PHPackages                             bitwerft/json-include - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. bitwerft/json-include

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

bitwerft/json-include
=====================

Provides functionality to include content of JSON files into another JSON files.

1.0.0(1y ago)0104MITPHPPHP ^8.1

Since Feb 24Pushed 1y agoCompare

[ Source](https://github.com/bitwerft/json-include)[ Packagist](https://packagist.org/packages/bitwerft/json-include)[ RSS](/packages/bitwerft-json-include/feed)WikiDiscussions main Synced 1mo ago

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

JSON Include
============

[](#json-include)

This allows you to use `#include` within `.json` files, so you can break up large json files into multiple smaller ones.

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

[](#installation)

**Through [composer](https://getcomposer.org/):**

- Simply execute `composer require bitwerft/json-include`

Usage
-----

[](#usage)

**1. JSON File**

- In your json file add a "#include" as the key, with the name (if in the same folder) or the path to the file as the value
- This can be in the middle of an array, as the only array element or nested deep in the file. The content of the included json will be placed at the exact same place.
- This file needs to be a valid json
- There is a maximum Number of includes, which is by default set to 100 to prevent circular includes
- `use Bitwerft\JsonInclude\JsonInclude;`
- **Execute using `JsonInclude::render('filename.json');`**

**2. Included JSON Files**

- The included files need to be valid json themselves
- They don't need to have the `.json` file extension
- Every file can be included multiple times
- They can also have "#include"s, which will be included recursivly
- Circular includes will cause an error

**3. Result**

- The assembled json will be returned as an unformatted string
- By default if any include fails, an Exception containing all info will be thrown
- The last used info array can also be accesed through `JsonInlude::$info`

Example
-------

[](#example)

1. JSON File

```
{
    "text": [
        {"#include":"http://example.com/file.json"}
    ],

    "#include":"file:///storage/app/file2.json"
}

```

2. JSON Include 1 ()

```
{
    "paragraph1": {
        "sentence": "Lorem ipsum"
    },
    "paragraph2": {
        "sentence": "dolor sit amet"
    }
}

```

2. JSON Include 2 (file:///storage/app/file2.json)

```
{
"ids": [1, 2, 3, 4, 5]
}

```

3. Result (with added formatting)

```
{
    "text":[
        {
            "paragraph1": {
                "sentence":"Lorem ipsum"
            },

            "paragraph2": {
                "sentence":"dolor sit amet"
            }
        }
    ],
    "ids": [1,2,3,4,5]
}

```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance44

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57.1% 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

Unknown

Total

1

Last Release

448d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/88d7f6ec0860139e766534a14283568b127c910080250fa2bb91f83dffff7d65?d=identicon)[Mattis](/maintainers/Mattis)

---

Top Contributors

[![MattisPrehm](https://avatars.githubusercontent.com/u/198934722?v=4)](https://github.com/MattisPrehm "MattisPrehm (4 commits)")[![jkr-bitwerft](https://avatars.githubusercontent.com/u/198883808?v=4)](https://github.com/jkr-bitwerft "jkr-bitwerft (3 commits)")

### Embed Badge

![Health badge](/badges/bitwerft-json-include/health.svg)

```
[![Health](https://phpackages.com/badges/bitwerft-json-include/health.svg)](https://phpackages.com/packages/bitwerft-json-include)
```

PHPackages © 2026

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