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

ActiveCakephp-plugin[HTTP &amp; Networking](/categories/http)

ahmedebead/cake-rest-api
========================

Rest API plugin for CakePHP 4.x

0.1(4y ago)25MITPHPPHP &gt;=7.2.0

Since Jul 8Pushed 4y ago1 watchersCompare

[ Source](https://github.com/ahmed3bead/cake-rest-api)[ Packagist](https://packagist.org/packages/ahmedebead/cake-rest-api)[ RSS](/packages/ahmedebead-cake-rest-api/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

CakeRestApi Plugin for CakePHP
==============================

[](#cakerestapi-plugin-for-cakephp)

[![Latest Stable Version](https://camo.githubusercontent.com/13b7ed205628dfdf3431a8f512e7784e0d53ae9dc2d3683ea58c85e14ab93316/687474703a2f2f706f7365722e707567782e6f72672f61686d656465626561642f63616b652d726573742d6170692f76)](https://packagist.org/packages/ahmedebead/cake-rest-api) [![Total Downloads](https://camo.githubusercontent.com/fb579214e4c69a92f0f54678449d775504e76ae28cfe6f05d6a96a18760d13bd/687474703a2f2f706f7365722e707567782e6f72672f61686d656465626561642f63616b652d726573742d6170692f646f776e6c6f616473)](https://packagist.org/packages/ahmedebead/cake-rest-api) [![Latest Unstable Version](https://camo.githubusercontent.com/f515ef4e8cad760d0563531d73ba9b349646649877758b1ae4c8cd989d418fff/687474703a2f2f706f7365722e707567782e6f72672f61686d656465626561642f63616b652d726573742d6170692f762f756e737461626c65)](https://packagist.org/packages/ahmedebead/cake-rest-api) [![License](https://camo.githubusercontent.com/1d1a6a9be77bcb3b37c26e974c706d50f03d91917b4b5a0d8f1d47bccc9097e6/687474703a2f2f706f7365722e707567782e6f72672f61686d656465626561642f63616b652d726573742d6170692f6c6963656e7365)](https://packagist.org/packages/ahmedebead/cake-rest-api)

This plugin simplifies the CakeRestApi API development for your CakePHP 4.x application. It simply converts the output of your controller into a JSON response.

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 ahmedebead/cake-rest-api "^0.1"

```

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

Add this file to /src/Application.php

```
// src/Application.php

 public function bootstrap(): void
    {
        $this->addPlugin('CakeRestApi', ['bootstrap' => true]);

        // Other code
    }
```

Or, you can load the plugin using the shell command

```
$ bin/cake plugin load CakeRestApi
```

Usage
-----

[](#usage)

No major change requrires in the way you code in your CakePHP application. Simply, just add one parameter to your route configuration `isRest` like,

```
$routes->connect('/foo/bar', ['controller' => 'Foo', 'action' => 'bar', 'isRest' => true]);
```

And extend your controller to `RestController` and everything will be handled by the plugin itself. For example,

```
