PHPackages                             cdgco/php-rest-service - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. cdgco/php-rest-service

ActiveLibrary[HTTP &amp; Networking](/categories/http)

cdgco/php-rest-service
======================

PHP REST Service is a simple and fast PHP class for server side RESTful APIs.

v0.2.4(3y ago)2151MITPHPPHP &gt;=7.4.0CI passing

Since Aug 2Pushed 10mo agoCompare

[ Source](https://github.com/cdgco/php-rest-service)[ Packagist](https://packagist.org/packages/cdgco/php-rest-service)[ RSS](/packages/cdgco-php-rest-service/feed)WikiDiscussions master Synced 1mo ago

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

PHP REST Service
================

[](#php-rest-service)

PHP REST Service is a simple and fast PHP class for RESTful JSON APIs.

[![Build Status](https://camo.githubusercontent.com/a4ffad1817539ad2e9bc68e9ec4b244cca9b96996be83606bc45be58653ced56/68747470733a2f2f696d672e736869656c64732e696f2f636972636c6563692f6275696c642f6769746875622f636467636f2f7068702d726573742d736572766963653f7374796c653d666c61742d737175617265)](https://app.circleci.com/pipelines/github/cdgco/php-rest-service)[![PHP Version](https://camo.githubusercontent.com/3aedaf63327cc1a8d3273ce6105ce5ba11f1673fcdef83ad70cffa825c928616/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f636467636f2f7068702d726573742d736572766963653f7374796c653d666c61742d737175617265)](https://www.php.net/downloads)[![Package Version](https://camo.githubusercontent.com/e446ad0fa20e09fbc301278c57c75e0324a21092b7f567fa1482662d482bc42f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636467636f2f7068702d726573742d736572766963653f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cdgco/php-rest-service)[![License](https://camo.githubusercontent.com/916e887d87f2091bb86b01cfef19e9a5148303f927301b61552d9a97e07e205a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f636467636f2f7068702d726573742d736572766963653f7374796c653d666c61742d737175617265)](https://github.com/cdgco/php-rest-service/blob/master/LICENSE)

Features
--------

[](#features)

- Easy to use syntax
- Regular Expression support
- Error handling through PHP Exceptions
- JSON, XML, and plain text responses
- Automatic OpenAPI specification generation
- Parameter validation through PHP function signature
- Can return a summary of all routes or one route through `OPTIONS` method based on PHPDoc (if `OPTIONS` is not overridden)
- Support of `GET`, `POST`, `PUT`, `DELETE`, `PATCH`, `HEAD` and `OPTIONS`
- Suppress the HTTP status code with ?\_suppress\_status\_code=1 (for clients that have troubles with that)
- Supports custom error handling, logging, access control and response formatting functions.
- Supports ?\_method=`httpMethod` as addition to the actual HTTP method.
- With auto-generation through PHP's `reflection`

Requirements
------------

[](#requirements)

- PHP 7.4+ (Tested on PHP 7.4 - 8.2)

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

[](#installation)

`php composer require cdgco/php-rest-service`

Demo
----

[](#demo)

### Manual Endpoint Creation

[](#manual-endpoint-creation)

```
use RestService\Server;

Server::create('/')
  ->addGetRoute('test/(\D+)', function($param){
    return 'Yay!' . $param; // $param pulled from URL capture group
  })
  ->addPostRoute('foo', function($field1) {
    return 'Hello ' . $field1; // same as "return 'Hello ' . $_POST('field1');"
  })
  ->addGetRoute('use/this/name', function(){
      return 'Hi there';
  })
->run();
```

### Automatic Endpoint Creation

[](#automatic-endpoint-creation)

```
namespace MyRestApi;

use RestService\Server;

class Admin {
  /*
   * @url /test/(\d+)
   */
  public function getTest($param) {
    return 'Yay!' . $param; // $param pulled from URL capture group
  }
  public function postFoo($field1){
    return 'Hello ' . $field1; // same as "return 'Hello ' . $_POST('field1');"
  }
  /*
   * @url /use/this/name
   */
  public function getNotThisName($field1){
    return 'Hi there';
  }
}

Server::create('/', 'myRestApi\Admin')
    ->collectRoutes()
->run();
```

Both methods will generate the following endpoints:

```
+ GET  /test/:param
+ POST /foo
+ GET  /use/this/name

```

Documentation
=============

[](#documentation)

Read the full documentation at .

License
-------

[](#license)

Licensed under the MIT License. See the LICENSE file for more details.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76.4% 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 ~66 days

Total

5

Last Release

1115d ago

PHP version history (2 changes)v0.2.0PHP &gt;=5.3.0

v0.2.1PHP &gt;=7.4.0

### Community

Maintainers

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

---

Top Contributors

[![cdgco](https://avatars.githubusercontent.com/u/13807630?v=4)](https://github.com/cdgco "cdgco (55 commits)")[![marcj](https://avatars.githubusercontent.com/u/450980?v=4)](https://github.com/marcj "marcj (4 commits)")[![ntvsx193](https://avatars.githubusercontent.com/u/2971095?v=4)](https://github.com/ntvsx193 "ntvsx193 (3 commits)")[![freinn](https://avatars.githubusercontent.com/u/2404609?v=4)](https://github.com/freinn "freinn (2 commits)")[![urkle](https://avatars.githubusercontent.com/u/101123?v=4)](https://github.com/urkle "urkle (2 commits)")[![superdave2u](https://avatars.githubusercontent.com/u/3734136?v=4)](https://github.com/superdave2u "superdave2u (1 commits)")[![mamartel](https://avatars.githubusercontent.com/u/1738891?v=4)](https://github.com/mamartel "mamartel (1 commits)")[![DeyV](https://avatars.githubusercontent.com/u/311626?v=4)](https://github.com/DeyV "DeyV (1 commits)")[![d-miles](https://avatars.githubusercontent.com/u/16198745?v=4)](https://github.com/d-miles "d-miles (1 commits)")[![bitdeli-chef](https://avatars.githubusercontent.com/u/3092978?v=4)](https://github.com/bitdeli-chef "bitdeli-chef (1 commits)")[![olect](https://avatars.githubusercontent.com/u/1047183?v=4)](https://github.com/olect "olect (1 commits)")

---

Tags

apiphprestrest-apirestfulserverphpapirestREST APIrestful

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cdgco-php-rest-service/health.svg)

```
[![Health](https://phpackages.com/badges/cdgco-php-rest-service/health.svg)](https://phpackages.com/packages/cdgco-php-rest-service)
```

###  Alternatives

[maurobonfietti/rest-api-slim-php

Example of REST API with Slim PHP Framework.

3061.7k](/packages/maurobonfietti-rest-api-slim-php)[colymba/silverstripe-restfulapi

SilverStripe RESTful API with a default JSON serializer.

6328.8k](/packages/colymba-silverstripe-restfulapi)[ismaeltoe/osms

PHP library wrapper of the Orange SMS API.

4540.0k](/packages/ismaeltoe-osms)[maurobonfietti/slim4-api-skeleton

Useful skeleton for RESTful API development, using PHP and Slim 4.

1392.3k](/packages/maurobonfietti-slim4-api-skeleton)

PHPackages © 2026

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