PHPackages                             meksiabdou/ci4-restful - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. meksiabdou/ci4-restful

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

meksiabdou/ci4-restful
======================

1.0.0(3y ago)47MITPHPPHP &gt;=7.3

Since Jul 3Pushed 3y ago1 watchersCompare

[ Source](https://github.com/meksiabdou/restful-codeigniter)[ Packagist](https://packagist.org/packages/meksiabdou/ci4-restful)[ RSS](/packages/meksiabdou-ci4-restful/feed)WikiDiscussions master Synced 2d ago

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

 [ ![](https://camo.githubusercontent.com/5b8d9090a678d487fbff6d0d7400659c2180a80374753a34de65cc380c2e2dca/68747470733a2f2f636f646569676e697465722e636f6d2f6173736574732f696d616765732f63692d6c6f676f2d6269672e706e67) ](https://codeigniter.com/)

CodeIgniter 4 RESTful &amp; Auth Api
====================================

[](#codeigniter-4-restful--auth-api)

CodeIgniter 4 RESTful &amp; Auth Api Resource Base Controller

[![License](https://camo.githubusercontent.com/909fc02ac625f9a847d9a87de4a7e15878372aab324dd2238dfcab6cfb8d62cf/68747470733a2f2f706f7365722e707567782e6f72672f79696461732f636f646569676e697465722d726573742f6c6963656e73653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/yidas/codeigniter-rest)

This RESTful API extension is collected into [composer require meksiabdou/ci4-restful](https://github.com/meksiabdou/restful-codeigniter) which is a complete solution for Codeigniter framework.

Features
--------

[](#features)

- ***Auth** use package myth/auth*
- ***RESTful API** implementation*
- ***Logs** Requests*

---

OUTLINE
-------

[](#outline)

- [Demonstration](#demonstration)
    - [RESTful Create Function](#restful-create-function)
- [Requirements](#requirements)
- [Installation](#installation)
- [Configuration](#configuration)

---

DEMONSTRATION
-------------

[](#demonstration)

```
use CI4Restful\Helpers\RestServer;

class ApiController extends RestServer
{
    public function index()
    {
        return $this->response_json(["id" => 1, "bar" => "foo" ]], true);
    }
}
```

Output with status `200 OK`:

```
{
    "results" : {
        "id": 1,
        "bar" : "foo",
    },
    "status" : true,
}
```

### RESTful Create Function

[](#restful-create-function)

```
public function store($requestData=null) {

    $this->db->insert('mytable', $requestData);
    $id = $this->db->insert_id();

    return $this->response->json(['id'=>$id], true , 201);
}
```

Output with status `201`:

```
{
    "results" : {
        "id": 1,
    },
    "status" : true,
}
```

Output with error

```
public function store($requestData=null) {

    if(!$requestData) {
        return $this->response->json([], false );
    }

}
```

```
{
    "results" : {},
    "status" : false,
}
```

Output with status `403 Forbidden`:

```
{
    "code": 403,
    "error":"API forbidden",
    "status" : false
}
```

---

REQUIREMENTS
------------

[](#requirements)

This library requires the following:

- PHP 7.4+
- CodeIgniter 4+
- [agungsugiarto/codeigniter4-cors](https://github.com/agungsugiarto/codeigniter4-cors)
- [myth/auth](https://github.com/lonnieezell/myth-auth)

---

INSTALLATION
------------

[](#installation)

Run Composer in your Codeigniter project:

```
composer require meksiabdou/ci4-restful

```

CONFIGURATION
-------------

[](#configuration)

### Config CORS [agungsugiarto/codeigniter4-cors](https://github.com/agungsugiarto/codeigniter4-cors/blob/master/README.md)

[](#config-cors-agungsugiartocodeigniter4-cors)

To allow CORS for all your routes, first register CorsFilter.php filter at the top of the $aliases property of App/Config/Filter.php class:

```
public $aliases = [
    'cors' => \Fluent\Cors\Filters\CorsFilter::class,
    // ...
];
```

Restrict routes based on their URI pattern by editing app/Config/Filters.php and adding them to the $filters array,

```
public filters = [
    // ...
    'cors' => ['after' => ['api/*']],
];
```

### Config Public Token

[](#config-public-token)

To access public routes generate token and add `$token_app` to app\\Config\\App.php

```
class App extends BaseConfig {

	public $token_app = ['2ve7Wq9P2QLnzQMlN2uVnBfb10xvOY0NQTuQ7Q'];

   //...
```

### Create a controller to extend `CI4Restful\Helpers\RestServer`,

[](#create-a-controller-to-extend-ci4restfulhelpersrestserver)

```
class Store extends RestServer {}
```

### Restful Auth API

[](#restful-auth-api)

```
https://yourname.com/api/login (POST)
https://yourname.com/api/register (POST)
https://yourname.com/api/logout (POST)
https://yourname.com/api/forgot-password (POST)
https://yourname.com/api/reset-password (POST)
https://yourname.com/api/update-user (PUT)
https://yourname.com/api/resend-activate-account (PUT)
https://yourname.com/api/p/update (for update password) (POST)

```

### HttpRequest (public routes)

[](#httprequest-public-routes)

```
const formData = new FormData();
formData.append('identity', 'user@email.com')
formData.append('password', 'password123');
var requestOptions = {
  method: 'POST',
  headers: {
    "token" : "2ve7Wq9P2QLnzQMlN2uVnBfb10xvOY0NQTuQ7Q"
   },
  body: formData,
  redirect: 'follow'
};

fetch("https://yourname.com/api/login", requestOptions)
  .then(response => response.json())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

### HttpRequest (private route)

[](#httprequest-private-route)

```
const formData = new FormData();
formData.append('email', 'user@email.com')
formData.append('password', 'password123');
formData.append('newPassword', 'newPassword123');
formData.append('confirmPassword', 'newPassword123');

var requestOptions = {
  method: 'PUT',
  headers: {
    "token" : userToken,
   },
   body: formData,
  redirect: 'follow'
};

fetch("https://yourname.com/p/update", requestOptions)
  .then(response => response.json())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

1409d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16627410?v=4)[Meksi Abdennour](/maintainers/meksiabdou)[@meksiabdou](https://github.com/meksiabdou)

---

Top Contributors

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

---

Tags

apiAuthenticationcodeigniterrestful

### Embed Badge

![Health badge](/badges/meksiabdou-ci4-restful/health.svg)

```
[![Health](https://phpackages.com/badges/meksiabdou-ci4-restful/health.svg)](https://phpackages.com/packages/meksiabdou-ci4-restful)
```

###  Alternatives

[league/oauth2-server

A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.

6.6k136.0M248](/packages/league-oauth2-server)[auth0/auth0-php

PHP SDK for Auth0 Authentication and Management APIs.

40820.2M68](/packages/auth0-auth0-php)[auth0/symfony

Symfony SDK for Auth0 Authentication and Management APIs.

128738.1k](/packages/auth0-symfony)[hasinhayder/tyro

Tyro - The ultimate Authentication, Authorization, and Role &amp; Privilege Management solution for Laravel 12 &amp; 13

6712.1k2](/packages/hasinhayder-tyro)[happyr/google-site-authenticator-bundle

Authenticate your website (not your users) with Google API. Can be used instead as Domain-Wide Delegation of Authority

1315.2k](/packages/happyr-google-site-authenticator-bundle)

PHPackages © 2026

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