PHPackages                             mvaliolahi/sibdoc - 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. mvaliolahi/sibdoc

ActiveLibrary

mvaliolahi/sibdoc
=================

PHP API Document Generator

v0.0.5(6y ago)11267↓100%1[1 PRs](https://github.com/mvaliolahi/sibdoc/pulls)MITPHP

Since Jan 15Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/mvaliolahi/sibdoc)[ Packagist](https://packagist.org/packages/mvaliolahi/sibdoc)[ Docs](https://mvaliolahi.ir)[ RSS](/packages/mvaliolahi-sibdoc/feed)WikiDiscussions master Synced today

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

SibDoc
------

[](#sibdoc)

[![Latest Stable Version](https://camo.githubusercontent.com/5526755d93f7922d2eeafb9cb506bd7f358cd94388bd205e781cba292517225c/68747470733a2f2f706f7365722e707567782e6f72672f6d76616c696f6c6168692f736962646f632f762f737461626c65)](https://packagist.org/packages/mvaliolahi/sibdoc)[![Total Downloads](https://camo.githubusercontent.com/b55099776a3555e61956d05aab737e1a6aa9a3c1590ee007888f85cea8529c40/68747470733a2f2f706f7365722e707567782e6f72672f6d76616c696f6c6168692f736962646f632f646f776e6c6f616473)](https://packagist.org/packages/mvaliolahi/sibdoc)[![Build Status](https://camo.githubusercontent.com/e140084747263dcf147648ce9489e650f600a08afc1c6966cdb2dde339368d0d/68747470733a2f2f7472617669732d63692e6f72672f6d76616c696f6c6168692f736962646f632e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mvaliolahi/sibdoc)[![PHP-Eye](https://camo.githubusercontent.com/802ca14b4ee877965a2b1913d6ca2d6157249cc96137a32e3dcd1f625a45aba5/68747470733a2f2f7068702d6579652e636f6d2f62616467652f6d76616c696f6c6168692f736962646f632f7465737465642e7376673f7374796c653d666c6174)](https://php-eye.com/package/mvaliolahi/sibdoc)[![PHPStan](https://camo.githubusercontent.com/441b5874ce4df0a2defc892979c96c46889b69cb32119d04f0b48626349f8bc9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d656e61626c65642d627269676874677265656e2e7376673f7374796c653d666c6174)](https://github.com/phpstan/phpstan)

Generate API Document Using Pure PHP.

[![](https://camo.githubusercontent.com/11ba2ad23e733dc851a24f06487418924a888e873e8f5796bd09d72643f66b30/68747470733a2f2f6d76616c696f6c6168692e6769746875622e696f2f6173736574732f696d616765732f736962646f6330312e6a7067)](https://camo.githubusercontent.com/11ba2ad23e733dc851a24f06487418924a888e873e8f5796bd09d72643f66b30/68747470733a2f2f6d76616c696f6c6168692e6769746875622e696f2f6173736574732f696d616765732f736962646f6330312e6a7067)

#### Install

[](#install)

```
composer require mvaliolahi/sibdoc
```

#### 1. Instantiate SibDoc.

[](#1-instantiate-sibdoc)

To generate document for your awesome API create an instance of SibDoc:

```
$api =  new SibDoc([
    'url'         => 'http://127.0.0.1:8000',
    'title'       => 'Our Awesome API',
    'description' => 'Generate API Document Using Lovely PHP.',
]);
```

- Tip: There is another optional argument called `'background_color => '#0099cc'` to specify Document background color.

#### 2. Define Endpoints

[](#2-define-endpoints)

```

$api->post('transactions/{id}', function (Request $request) {

    //  Define Request.
    $request->title('Show transaction.');
    $request->version("v1"); // Optional

    $request->parameters([
        'token' => 'required',
        'transaction_id' => 'required',
    ]);

    // Define Response.
    $success = (new Response())
        ->title('Success')
        ->code(200)
        ->body([
            'id'         => 'numeric',
            'status'     => 'PAID | UNPAID',
            'created_at' =>  'timestamp',
        ]);

    // Assings Reaponses to the Request.
    $request->response($success);

});
```

Tips:

- Request can have more than one response, just define another Response object and assign it to `$request`.
- $request-&gt;response('Success', $success); is another way to assign response to request and define alias for response.
- Request and Response they both have `description()` method, this method is optional.
- You can define Header for both Request and Response Objects using `headers()` method for example:

    `$request->headers([])`.

    or define a general header for those using `$api->requestHeaders([])` or `$api->responseHeaders([])` method.

[![](https://camo.githubusercontent.com/6f53719b7175c871b8d9e7c304a6a3b6a521e2f140fb4aff7c79988430f79967/68747470733a2f2f6d76616c696f6c6168692e6769746875622e696f2f6173736574732f696d616765732f736962646f6330322e6a7067)](https://camo.githubusercontent.com/6f53719b7175c871b8d9e7c304a6a3b6a521e2f140fb4aff7c79988430f79967/68747470733a2f2f6d76616c696f6c6168692e6769746875622e696f2f6173736574732f696d616765732f736962646f6330322e6a7067)

Available methods:

- get
- post
- put
- patch
- delete
- head
- connect
- options
- trace

###### Define Group

[](#define-group)

```

$api->group('app', function(SibDoc $api) {

    $api->delete('posts/{id}', function (Request $request) {
        // Define request and response.
    });

});
```

#### Define Model

[](#define-model)

```
$api->model('user', [
    'id'     => 'numeric',
    'name'   => 'string',
    'family' => 'string',
    'avatar' => 'url',
]);
```

##### Use model as part of response body

[](#use-model-as-part-of-response-body)

```
$api->get('users', function (Request $request) {

    $request->title('Get all users');
    $request->version(1.2);
    $request->description('...');
    $request->parameters(['token' => 'required']);

    $success = (new Response())
        ->title('Success')
        ->description('...')
        ->code(200)
        ->body([
            'data'  => [ $api->model('user') ] // when second argument is null it will act as getter.
        ]);

    $fail = (new Response())
        ->title('Fail')
        ->description('...')
        ->code(404)
        ->body([
            'data'  => []
        ]);

    $request->response($success);
    $request->response($fail);

});
```

#### 3. Generate Html

[](#3-generate-html)

By default SibDoc can generate a file called `document.html` for you.

```
$api->saveTo('/home/meysam/');
```

Tips:

- first argument specify export path, after call `saveTo()` method with related parameters, it will generate a file called `document.html` in that path.
- second argument refer to built-in Generator for create html file.
- you can define your custom generator to create you desire format, for example `markdown` or maybe `json` file. i will demonstrate to you right below!

##### Create Custom Generator

[](#create-custom-generator)

first of all you need a regular class and you should extends it from `DocumentGenerator` abstract class.

```
/**
 * Class FakeGenerator
 * @package Tests\Generators
 */
class FakeGenerator extends DocumentGenerator
{
    /**
     * @param $path
     * @return mixed
     */
    public function format($path)
    {
        return 'fake generator!';
    }
}
```

There are several method after extends your class that you can use to generate your custom format.

- groups()

    - gives you all defined groups. when group name is not string that's mean its not a group, means its a single endpoint.
- endpoints()

    - gives you an array contains all endpoints and group, each group can have several endpoint.
- models()
- backgroundColor()

    - gives you the `background_color` value from what you pass as SibDoc instance argument.

it up to you how use them and how is your final format.

at the end you should pass your generator as argument to SibDoc:

```
$api = new SibDoc([
    'url'         => 'http://127.0.0.1:8000',
    'title'       => 'SibDoc Document Generator',
    'description' => 'Generate Api Document Using Pure PHP.',
    'generator'   => [
        'fake_generator' => FakeGenerator::class
    ],
]);

// define you groups and endpoints

$api->saveTo('/home/user/', 'fake_generator');
```

###  Health Score

35

—

LowBetter than 81% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% 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 ~69 days

Total

5

Last Release

2346d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6d8a3eaee2623560bfdc9906358e1805abd4adf9fcd9170eba274fcfd8a51443?d=identicon)[mvaliolahi](/maintainers/mvaliolahi)

---

Top Contributors

[![mvaliolahi](https://avatars.githubusercontent.com/u/6920600?v=4)](https://github.com/mvaliolahi "mvaliolahi (8 commits)")[![aminrafiei](https://avatars.githubusercontent.com/u/25347159?v=4)](https://github.com/aminrafiei "aminrafiei (1 commits)")[![google-labs-jules[bot]](https://avatars.githubusercontent.com/in/842251?v=4)](https://github.com/google-labs-jules[bot] "google-labs-jules[bot] (1 commits)")

---

Tags

api-documentAPI Document GeneratorAPI Document Builder

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mvaliolahi-sibdoc/health.svg)

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

###  Alternatives

[maba/webpack-bundle

Bundle to Integrate Webpack to Symfony

122268.2k4](/packages/maba-webpack-bundle)[ezsystems/legacy-bridge

eZ Platform bridge to eZ Publish Legacy

17118.5k4](/packages/ezsystems-legacy-bridge)[privacyidea/simplesamlphp-module-privacyidea

Add multi-factor authentication to simpleSAMLphp. The second factors are managed in privacyIDEA.

242.4k](/packages/privacyidea-simplesamlphp-module-privacyidea)

PHPackages © 2026

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