PHPackages                             mind2minds/cakephp-rest-api - 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. mind2minds/cakephp-rest-api

ActiveCakephp-plugin[API Development](/categories/api)

mind2minds/cakephp-rest-api
===========================

CakePHP 3 plugin for building REST API services

1.0.2(7y ago)035MITPHP

Since Jun 19Pushed 7y ago1 watchersCompare

[ Source](https://github.com/mind2minds/cakephp-rest-api)[ Packagist](https://packagist.org/packages/mind2minds/cakephp-rest-api)[ RSS](/packages/mind2minds-cakephp-rest-api/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (2)Versions (4)Used By (0)

RestApi plugin for CakePHP 3
============================

[](#restapi-plugin-for-cakephp-3)

This plugin is used to create REST API endpoints.

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

[](#requirements)

This plugin has the following requirements:

- CakePHP 3.0.0 or greater.
- PHP 5.4.16 or greater.

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

[](#installation)

You can install this plugin into your CakePHP application using [composer](http://getcomposer.org).

The recommended way to install composer packages is:

```
composer require mind2minds/cakephp-rest-api

```

After installation, [Load the plugin](http://book.cakephp.org/3.0/en/plugins.html#loading-a-plugin)

```
Plugin::load('RestApi', ['bootstrap' => true]);
```

Or, you can load the plugin using the shell command

```
$ bin/cake plugin load -b RestApi
```

Usage
-----

[](#usage)

You just need to create your API related controller and extend it to `RestApi\Controller\AppController` instead of default `AppController`.

```
namespace App\Controller;

use RestApi\Controller\AppController;

/**
 * Demo Controller
 */
class DemoController extends AppController
{

    /**
     * Read contacts or single contact details when id given
     */
    public function contacts($id = null)
    {
        $contacts = [
            //...
        ];
        $result = [];
        if(!empty($id)) {
            if (empty($contacts[$id])) {
                $this->_error(404, 'Missing Contacts', 'Invalid Id Supplied');
            } else {
                $contact = $contacts[$id];
                $result = [
                    'Id' => $id,
                    'type' => 'Contact',
                    '_name' => $contact['name'],
                    '_email' => $contact['email']
                ];
            }
        } else {
            foreach ($contacts as $id => $contact) {
                $result[] = [
                    'Id' => $id,
                    'type' => 'Contact',
                    '_name' => $contact['name'],
                    '_email' => $contact['email']
                ];
            }
        }
        $this->_createJsonApiResponse($result);
    }
}
```

You can define your logic in your action function as per your need. For above example, you will get following response in `json` format (json response as per [jsonapi](http://jsonapi.org/) specs),

```
{
  "data": {
    "type": "contacts",
    "id": "1",
    "attributes": {
      // ... this contact's attributes
    },
    "relationships": {
      // ... this contact's relationships if any
    }
  }
}
```

The URL for above example will be `http://yourdomain.com/api/contacts`. You can customize it by setting the routes in `APP/config/routes.php`. Endpoint `/api/contacts` example is

```
$routes->connect('/api/contacts', ['plugin' => 'RestApi', 'controller' => 'Demo', 'action' => 'contacts']);
```

Accept basic http authentication header e.g. `Basic NzQxZjNhOTctZTBjNC00OTFjLWI3MDItY2JlYTA5NzVmODhl` this is for default demo api key

Its easy to use :)

Reporting Issues
----------------

[](#reporting-issues)

If you have a problem with this plugin or any bug, please open an issue on [GitHub](https://github.com/mind2minds/cakephp-rest-api/issues).

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity65

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

Total

3

Last Release

2887d ago

### Community

Maintainers

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

---

Top Contributors

[![DilshadKhan](https://avatars.githubusercontent.com/u/1314381?v=4)](https://github.com/DilshadKhan "DilshadKhan (6 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mind2minds-cakephp-rest-api/health.svg)

```
[![Health](https://phpackages.com/badges/mind2minds-cakephp-rest-api/health.svg)](https://phpackages.com/packages/mind2minds-cakephp-rest-api)
```

###  Alternatives

[friendsofcake/crud-json-api

Listener for building CakePHP Crud APIs following the JSON API specification.

58445.4k3](/packages/friendsofcake-crud-json-api)[alt3/cakephp-swagger

Instant Swagger documentation for your CakePHP 4.x APIs

64197.3k3](/packages/alt3-cakephp-swagger)[cnizzardini/cakephp-swagger-bake

Automatically generate OpenApi, Swagger, and Redoc documentation from your existing cakephp project

60171.2k4](/packages/cnizzardini-cakephp-swagger-bake)[bcrowe/cakephp-api-pagination

CakePHP 4 plugin that injects pagination information into API responses.

3953.5k1](/packages/bcrowe-cakephp-api-pagination)[gourmet/social-meta

Adds Facebook Open Graph and Twitter Cards support to CakePHP 3.x

255.1k](/packages/gourmet-social-meta)

PHPackages © 2026

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