PHPackages                             linusshops/magicdoc - 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. linusshops/magicdoc

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

linusshops/magicdoc
===================

Autogenerate phpdoc for magic methods from json documents

0.3.6(9y ago)021[3 issues](https://github.com/linusshops/magicdoc/issues)MITPHPPHP &gt;=5.5.0

Since Nov 30Pushed 9y ago1 watchersCompare

[ Source](https://github.com/linusshops/magicdoc)[ Packagist](https://packagist.org/packages/linusshops/magicdoc)[ Docs](https://github.com/linusshops/prophet)[ RSS](/packages/linusshops-magicdoc/feed)WikiDiscussions master Synced today

READMEChangelog (9)Dependencies (2)Versions (6)Used By (0)

magicdoc
========

[](#magicdoc)

Magicdoc automatically generates @method documentation for known magic method options from a JSON document. The top level elements of the JSON file will be scanned, and used to create @method lines in the destination class file.

Impetus
-------

[](#impetus)

When connecting to an external api, it returned a JSON document with many properties. As the api had many endpoints, and many possible returnable properties, it would not be a good use of time to concretely implement every single one.

Instead, an approach using the `__call` magic method was used. The JSON document was read into an internal array, and the `__call` method was implemented to look at the name of the called method and any parameters provided to find the desired property. By using magic methods instead of object properties, it allowed descent into the JSON document without needing intermediary variables or loops.

This left the issue of having many possible available properties, and wanting IDE hinting on them, solved by magicdoc.

Configuration
-------------

[](#configuration)

Magicdoc expects a magicdoc.json file. This file should be an array of objects, each object representing a json document and a class that it will be mapped to.

```
[
  {
    "source":"example.json",
    "destination":"src/LinusShops/ExampleClass.php",
    "types" : {
      "items" : "Item[]"
    },
    "parameters" : {
      "items" : "$parameter1, $parameter2"
    }
  }
]

```

`source`: required, specifies the location of the json file to map

`destination`: required, the location of the destination class

`types`: optional, allows specifying types for certain elements. Magicdoc will infer basic types (string, bool, integer), but this allows to specify objects.

`parameters`: optional, allows specifying a list of arguments. Magicdoc will default to a standard variadic parameter (...$parameters)

Finally, the destination class must have the `{{magicdoc_start}}` and `{{magicdoc_end}}`tags added in the location you want the @method listing to appear. Generally, this is in the class docblock.

Url configuration
-----------------

[](#url-configuration)

Magicdoc can also read directly from your api.

```
[
  {
    "source":{
      "type": "url",
      "url": "http://example.com/endpoint",
      "headers": {
        "Authorization": "Some token",
        "Content-Type":"application/json"
      },
      "body":"{\"option\":\"hello\"}",
      "method":"POST"
    },
    "destination":"src/LinusShops/Example.php",
    "options":{
      "bust_wrapper_array":true
    }
  }
]

```

`source`: specifies the options to pass to make the api request. The following options are not required- headers, body, method (defaults to GET).

`options`: specifies actions to take with the received json, mostly preprocessing

`options=>bust_wrapper_array`: if your API wraps returned objects in an array, you can set this option to pop the first object out of the array to be used for documentation generation.

Magento Model IDE Helper
------------------------

[](#magento-model-ide-helper)

Magicdoc can also generate an IDE helper for magic getters/setters in Magento models.

```
{
    "source":{
      "type": "magento",
      "model": "linus_example/product",
      "id": 1
    }
}

```

Magicdoc expects the magicdoc.json file to be in the root of your magento installation.

The provided id should be a valid instance of the model, as magicdoc will inspect the types of the data contained to determine accurate return types. It will then generate a `__mage_ide_helper.php` file, which should be placed in the root of your magento project.

Usage
-----

[](#usage)

Run `magicdoc` from the directory containing your magicdoc.json.

\##License MIT

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 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 ~82 days

Total

5

Last Release

3535d ago

PHP version history (2 changes)0.2.0PHP &gt;=5.3

v0.3.4PHP &gt;=5.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/8fa6044a587e4dd9355bd68d6c3a31c628cc26752e600c81074e0049ec383688?d=identicon)[linusshops](/maintainers/linusshops)

---

Top Contributors

[![dersam](https://avatars.githubusercontent.com/u/475851?v=4)](https://github.com/dersam "dersam (36 commits)")

---

Tags

json-documentmagicmagic-methodsphputilitymagentomodulelinus shopsmx canadacanadas motorcyclemagicdoc

### Embed Badge

![Health badge](/badges/linusshops-magicdoc/health.svg)

```
[![Health](https://phpackages.com/badges/linusshops-magicdoc/health.svg)](https://phpackages.com/packages/linusshops-magicdoc)
```

###  Alternatives

[spatie/laravel-export

Create a static site bundle from a Laravel app

672139.5k6](/packages/spatie-laravel-export)[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

5.1k4.9k](/packages/shlinkio-shlink)[run-as-root/magento2-prometheus-exporter

Magento2 Prometheus Exporter

68353.9k](/packages/run-as-root-magento2-prometheus-exporter)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[eliashaeussler/typo3-solver

Solver - Extends TYPO3's exception handling with AI generated solutions. Problems can also be solved from command line. Several OpenAI parameters are configurable and prompts and solution providers can be customized as desired.

302.1k](/packages/eliashaeussler-typo3-solver)[aeliot/todo-registrar

Register TODOs from source code in issue tracker

153.0k](/packages/aeliot-todo-registrar)

PHPackages © 2026

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