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

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

vudp/cakephp-rest-api
=====================

CakePHP 4 plugin to provide basic support for building REST API services

1.0(5y ago)4871MITPHPPHP &gt;=7.2.0

Since Jan 14Pushed 5y ago1 watchersCompare

[ Source](https://github.com/artvudp/cakephp-rest-api)[ Packagist](https://packagist.org/packages/vudp/cakephp-rest-api)[ Docs](https://github.com/cakephp/debug_kit)[ RSS](/packages/vudp-cakephp-rest-api/feed)WikiDiscussions main Synced 6d ago

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

RestApi plugin for CakePHP 4.2.2
================================

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

Our packagist repo:
--------------------------------------------------------------------------

[](#our-packagist-repo-httpspackagistorgpackagesvudpcakephp-rest-api)

This plugin provides basic support for building REST API services in your CakePHP 4 application. Read a detailed guide on how to implement below.

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

[](#requirements)

This plugin has the following requirements:

- CakePHP 4.2.2 or greater.
- PHP 7.2 or greater.

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

[](#installation)

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

After that, you can setup our package by standing at orginal folder of your project and running

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

```

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

```
$this->addPlugin('RestApi');
```

Or, you can load the plugin using the shell command

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

The complete code of "bootstrap" function at src/Application.php where you just added your RestApi plugin.

```
 public function bootstrap(): void
    {
        $this->addPlugin('RestApi');

        // Call parent to load bootstrap from files.
        parent::bootstrap();

        if (PHP_SAPI === 'cli') {
            $this->bootstrapCli();
        } else {
            FactoryLocator::add(
                'Table',
                (new TableLocator())->allowFallbackClass(false)
            );
        }

        /*
         * Only try to load DebugKit in development mode
         * Debug Kit should not be installed on a production system
         */
        if (Configure::read('debug')) {
            $this->addPlugin('DebugKit');
        }

        // Load more plugins here
    }

```

Usage
-----

[](#usage)

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

Configurations
--------------

[](#configurations)

The default configurations are as below and defined in `RestApi/config/api.php`.

```
