PHPackages                             woohoolabs/spec-generator - 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. [API Development](/categories/api)
4. /
5. woohoolabs/spec-generator

ActiveLibrary[API Development](/categories/api)

woohoolabs/spec-generator
=========================

Woohoo Labs. Spec Generator

0.5.0(9y ago)6661MITPHPPHP &gt;=5.4.0

Since Oct 23Pushed 9y ago1 watchersCompare

[ Source](https://github.com/woohoolabs/spec-generator)[ Packagist](https://packagist.org/packages/woohoolabs/spec-generator)[ RSS](/packages/woohoolabs-spec-generator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (3)Versions (10)Used By (0)

Woohoo Labs. Spec Generator
===========================

[](#woohoo-labs-spec-generator)

**Generate various specifications (e.g. Swagger Spec 2.0) in perfect sync with your real code via object-oriented PHP!**

Introduction
------------

[](#introduction)

This library aims to foster creating configurations and specifications which would be written in structured data formats (like JSON, XML, YML). Not only these files can grow extremely long, but they can easily become a nightmare from a maintenance point of view. For example, let's take the [Swagger 2.0](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md)specification: the documentation of an API with only a handful of resources can easily go over one thousand of lines. That's why it requires a great effort to have a good overview on the document.

Another problem is that the live software and its specification usually diverges from each other over time as the maintaining staff is too busy/negligent/forgetful to synchronize them. Woohoo Labs. Spec Generator tries to shorten the gap between them: the main idea is to generate documents supported by the glorious object-oriented features right from your application's code!

When talking about creating documentations, you could ask what the point is in writing these documents by hand, when some of them (e.g. Swagger docs) could be generated by frameworks which use annotations for the definitions. While this is a valid point, there are yet some major drawbacks of this approach (it is called reverse-engineering):

- **It is not forward-engineering:** Sometimes you need to design something before you ship it :)
- **Your specification/documentation will be fragmented:** there won't be any single place to look for these definitions. That's why if you need to change something in multiple places then it won't be easy.
- **You won't benefit from the capabilities of PHP:** You can't extend classes, can't read data from files or even constants, can't have code completion from your IDE etc. This undermines real consistency.

Features
--------

[](#features)

- Support for Swagger 2.0 API documentation
- Different output formats (array, JSON, XML, YML)
- Specification can be cached for improved performance

Basic Usage
-----------

[](#basic-usage)

Advanced Usage
--------------

[](#advanced-usage)

#### Caching

[](#caching)

```
use Doctrine\Common\Cache\MemcachedCache;
use WoohooLabs\SpecGenerator\Swagger2\SwaggerSpec;
use WoohooLabs\SpecGenerator\Swagger2\Info\Contact;
use WoohooLabs\SpecGenerator\Swagger2\Info\MitLicense;

$memcached = new \Memcached();
$memcached->addServer("localhost", 11211);
$cache = new MemcachedCache();
$cache->setMemcached($memcached);

SwaggerSpec::getSpecification(
    function(SwaggerSpec $swagger) {
        $info= Info::create()
            ->setTitle("API Title")
            ->setVersion("1.0.0")
            ->setDescription("API Description")
            ->setContact(new Contact("Sam Support", "123-456-789", "samsupport@example.com"))
            ->setLicense(new MitLicense())
        ;

        return $swagger
            ->setInfo($info)
            ->setBasePath("/")
            ->setConsumes(["application/json"])
            ->setSchemes(["http"])
            ->setProduces(["application/vnd.hal+json"])
            ->generate();
    },
    $cache
);
```

License
-------

[](#license)

The MIT License (MIT). Please see the [License File](https://github.com/woohoolabs/spec-generator/blob/master/LICENSE.md)for more information.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.9% 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 ~78 days

Recently: every ~112 days

Total

9

Last Release

3600d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b84c2c00735d2c7408e53566b0a622d39998be610bc02856e1b887d40f7a8024?d=identicon)[woohoolabs](/maintainers/woohoolabs)

---

Top Contributors

[![kocsismate](https://avatars.githubusercontent.com/u/6057627?v=4)](https://github.com/kocsismate "kocsismate (52 commits)")[![niels-nijens](https://avatars.githubusercontent.com/u/3245362?v=4)](https://github.com/niels-nijens "niels-nijens (3 commits)")[![sagikazarmark](https://avatars.githubusercontent.com/u/1226384?v=4)](https://github.com/sagikazarmark "sagikazarmark (1 commits)")

---

Tags

specificationswaggergeneratorWoohoo Labs.

### Embed Badge

![Health badge](/badges/woohoolabs-spec-generator/health.svg)

```
[![Health](https://phpackages.com/badges/woohoolabs-spec-generator/health.svg)](https://phpackages.com/packages/woohoolabs-spec-generator)
```

###  Alternatives

[swagger-api/swagger-ui

 Swagger UI is a collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.

28.7k45.4M99](/packages/swagger-api-swagger-ui)[darkaonline/l5-swagger

OpenApi or Swagger integration to Laravel

2.9k34.0M112](/packages/darkaonline-l5-swagger)[darkaonline/swagger-lume

OpenApi or Swagger integration to Lumen

3372.3M3](/packages/darkaonline-swagger-lume)[infyomlabs/swagger-generator

Swagger Generator for InfyOm Laravel Generator

1151.1M5](/packages/infyomlabs-swagger-generator)[psx/api

Parse and generate API specification formats

37178.0k4](/packages/psx-api)[mezatsong/laravel-swagger-docs

Swagger docs generator for Laravel api

2457.4k](/packages/mezatsong-laravel-swagger-docs)

PHPackages © 2026

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