PHPackages                             appserver-io/restapi - 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. appserver-io/restapi

ActiveLibrary

appserver-io/restapi
====================

Servlet based library that provides basic functionality to implement an API that is compatible with the OpenAPI 2.0 specification.

2.0.0(5y ago)0401OSL-3.0PHPPHP &gt;=5.6.0

Since Sep 13Pushed 5y ago4 watchersCompare

[ Source](https://github.com/appserver-io/restapi)[ Packagist](https://packagist.org/packages/appserver-io/restapi)[ Docs](https://github.com/appserver-io/restapi)[ RSS](/packages/appserver-io-restapi/feed)WikiDiscussions 2.0.x Synced 2mo ago

READMEChangelogDependencies (6)Versions (12)Used By (0)

RESTFul API
===========

[](#restful-api)

[![Latest Stable Version](https://camo.githubusercontent.com/c52a5dacc84b4edf6dab37499b39592549edd4b05dddb51e5c3c01037eb36a4c/68747470733a2f2f706f7365722e707567782e6f72672f6170707365727665722d696f2f726573746170692f762f737461626c652e706e67)](https://packagist.org/packages/appserver-io/restapi)[![Total Downloads](https://camo.githubusercontent.com/905a2b95359d3e458b09b2301026fe42382d304f4f2f83bdc14b627a0a7dc5eb/68747470733a2f2f706f7365722e707567782e6f72672f6170707365727665722d696f2f726573746170692f646f776e6c6f6164732e706e67)](https://packagist.org/packages/appserver-io/restapi)[![License](https://camo.githubusercontent.com/ea75e83d232a3b0f01d94e282fe02dbf52a6b14828755fc60c33091cd2543230/68747470733a2f2f706f7365722e707567782e6f72672f6170707365727665722d696f2f726573746170692f6c6963656e73652e706e67)](https://packagist.org/packages/appserver-io/restapi)[![Build Status](https://camo.githubusercontent.com/db85cf47030a23144f75429856c9872f56c63961fd6ceae7ed0d9662de9df12e/68747470733a2f2f7472617669732d63692e6f72672f6170707365727665722d696f2f726573746170692e706e67)](https://travis-ci.org/appserver-io/restapi)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/1951a3a44162d359b9a3a1fb5efd1be82842db6bb91ea0042ee15a422c58a900/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6170707365727665722d696f2f726573746170692f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/appserver-io/restapi/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/26e5ad00439b096fd93683dfb8412901ee18afd699364490d993e12891c8db92/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6170707365727665722d696f2f726573746170692f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/appserver-io/restapi/?branch=master)

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

[](#introduction)

RESTFul API provides a simple framework that makes the implemention of a OpenApi 2 (verion 3 is still to come) server pretty simple.

Actually the library only supports a subset of the OpenApi 2 functionality, but we'll add additional during the time.

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

[](#installation)

If you want to write an application that uses RESTFul API, you have to install it using Composer. To do this, simply add it to the dependencies in your `composer.json`

```
{
    "require": {
        "appserver-io/restapi": "~1.0"
    }
}
```

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

[](#configuration)

Simply register the two servlets `AppserverIo\RestApi\Servlets\SwaggerServlet` and `AppserverIo\RestApi\Servlets\ApiServlet` in the `WEB-INF/web.xml` file. The main description of your webservices can be done through the annotations of Rob Allens library [zircote/swagger-php](https://github.com/zircote/swagger-php/tree/2.x).

### The Servlet Configuration

[](#the-servlet-configuration)

The configuration has to be done in the `WEB-INF/web.xml` file as shown in this example

```

    my-api
    My API web application

        my-api/session-name>
        my-api_session_

        A servlet that handles DHTML files.
        The DHTML Servlet
        dhtml
        AppserverIo\Appserver\ServletEngine\Servlets\DhtmlServlet

        A servlet that renders the content of the Swagger definition.
        The Swgger Servlet
        swagger
        AppserverIo\RestApi\Servlets\SwaggerServlet

        A servlet that handles the RESTFul API requests.
        The API Servlet
        api
        AppserverIo\RestApi\Servlets\ApiServlet

            RequestHandlerFactory
            RequestHandlerFactory

                AppserverIo\RestApi\Servlets\ApiServlet
                requestHandlerFactory

          api
          OA2

        dhtml
        *.dhtml

        swagger
        /swagger.do

        api
        /api.do

        500
        /dhtml/500.dhtml

```

### Annotate the Beans

[](#annotate-the-beans)

After the web application has been configured, simple annotate the classes that you want to expose as webserver with the necessary annotations like

```
/**
 * A SLSB implementation providing some API functionality.
 *
 * @EPB\Stateless
 *
 * @SWG\Info(
 *     title="My API",
 *     version="1.0.0"
 * )
 *
 * @SWG\Swagger(
 *   schemes={"http"},
 *   host="127.0.0.1:9080",
 *   basePath="/my-api/api.do"
 * )
 */
class SomeProcessor
{

    /**
     * Returns the DTO with the passed ID.
     *
     * @param integer $id The ID of the DTO to return
     *
     * @return \Ma\Api\Dtos\MyDto The DTO with the data
     *
     * @SWG\Get(
     *     path="/traveltaxpackages/{id}",
     *     operationId="find",
     *     produces={"application/json"},
     *     @SWG\Parameter(
     *         name="id",
     *         in="path",
     *         description="The ID of the DTO to return",
     *         required=true,
     *         type="integer"
     *     ),
     *     @SWG\Response(
     *         response="200",
     *         description="The DTO",
     *         @SWG\Schema(
     *             ref="#/definitions/MyDto"
     *         )
     *     )
     * )
     */
    public function find($id)
    {
        // return an array with serializable DTOs here
    }
}
```

Usage
-----

[](#usage)

Open the browser and enter the URL  which should result in rendering the Swagger configuration.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity63

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

Recently: every ~16 days

Total

11

Last Release

1832d ago

Major Versions

1.2.x-dev → 2.0.02021-05-03

### Community

Maintainers

![](https://www.gravatar.com/avatar/76b54aaecf7287a0520eec0009161ca457982dee83ac413bfa0d818b72d79947?d=identicon)[wagnert](/maintainers/wagnert)

---

Top Contributors

[![wagnert](https://avatars.githubusercontent.com/u/287509?v=4)](https://github.com/wagnert "wagnert (28 commits)")

### Embed Badge

![Health badge](/badges/appserver-io-restapi/health.svg)

```
[![Health](https://phpackages.com/badges/appserver-io-restapi/health.svg)](https://phpackages.com/packages/appserver-io-restapi)
```

###  Alternatives

[nelmio/api-doc-bundle

Generates documentation for your REST API from attributes

2.3k63.6M232](/packages/nelmio-api-doc-bundle)[darkaonline/l5-swagger

OpenApi or Swagger integration to Laravel

2.9k34.0M111](/packages/darkaonline-l5-swagger)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[horstoeko/zugferd

A library for creating and reading european electronic invoices

4044.3M17](/packages/horstoeko-zugferd)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)

PHPackages © 2026

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