PHPackages                             takuya-motoshima/codeigniter-extension - 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. [Framework](/categories/framework)
4. /
5. takuya-motoshima/codeigniter-extension

ActiveLibrary[Framework](/categories/framework)

takuya-motoshima/codeigniter-extension
======================================

Extend CodeIgniter for ease of use

v5.0.9(4w ago)25.3k↑50%MITJavaScriptPHP ^7.3CI passing

Since Oct 23Pushed 4w agoCompare

[ Source](https://github.com/shumatsumonobu/codeigniter-extension)[ Packagist](https://packagist.org/packages/takuya-motoshima/codeigniter-extension)[ RSS](/packages/takuya-motoshima-codeigniter-extension/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (10)Dependencies (40)Versions (459)Used By (0)

 [![Version](https://camo.githubusercontent.com/717b3b2022c29680d221700c0b67288831a46215403c2269da3aa0ec9dc5efb3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74616b7579612d6d6f746f7368696d612f636f646569676e697465722d657874656e73696f6e3f7374796c653d666c61742d73717561726526636f6c6f723d303037626666)](https://camo.githubusercontent.com/717b3b2022c29680d221700c0b67288831a46215403c2269da3aa0ec9dc5efb3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74616b7579612d6d6f746f7368696d612f636f646569676e697465722d657874656e73696f6e3f7374796c653d666c61742d73717561726526636f6c6f723d303037626666) [![Downloads](https://camo.githubusercontent.com/e64a48b10e0f94ea9fb12dd04774a580dae1504cd73146cf8445a340f5dac79b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f74616b7579612d6d6f746f7368696d612f636f646569676e697465722d657874656e73696f6e3f7374796c653d666c61742d73717561726526636f6c6f723d323861373435)](https://camo.githubusercontent.com/e64a48b10e0f94ea9fb12dd04774a580dae1504cd73146cf8445a340f5dac79b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f74616b7579612d6d6f746f7368696d612f636f646569676e697465722d657874656e73696f6e3f7374796c653d666c61742d73717561726526636f6c6f723d323861373435) [![PHP](https://camo.githubusercontent.com/8fb30612a89a308267bbe22a1faea2c3fb53293bb5529d8eeb655281ad64d856/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f74616b7579612d6d6f746f7368696d612f636f646569676e697465722d657874656e73696f6e3f7374796c653d666c61742d73717561726526636f6c6f723d366634326331)](https://camo.githubusercontent.com/8fb30612a89a308267bbe22a1faea2c3fb53293bb5529d8eeb655281ad64d856/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f74616b7579612d6d6f746f7368696d612f636f646569676e697465722d657874656e73696f6e3f7374796c653d666c61742d73717561726526636f6c6f723d366634326331) [![License](https://camo.githubusercontent.com/e99f98a9a2c9928163af2a78d026abcdcd4028199e98869a944d33a20563b974/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f74616b7579612d6d6f746f7368696d612f636f646569676e697465722d657874656e73696f6e3f7374796c653d666c61742d73717561726526636f6c6f723d366337353764)](https://camo.githubusercontent.com/e99f98a9a2c9928163af2a78d026abcdcd4028199e98869a944d33a20563b974/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f74616b7579612d6d6f746f7368696d612f636f646569676e697465722d657874656e73696f6e3f7374796c653d666c61742d73717561726526636f6c6f723d366337353764)

CodeIgniter Extension
=====================

[](#codeigniter-extension)

 **Supercharge your CodeIgniter 3 workflow.**
 Extended controllers, models, utilities, and AWS integrations — all in one package.

 [日本語](README_ja.md) | [Changelog](CHANGELOG.md) | [API Docs](https://shumatsumonobu.github.io/codeigniter-extension/)

Why CodeIgniter Extension?
--------------------------

[](#why-codeigniter-extension)

CodeIgniter 3 is fast and lightweight — but it lacks modern conveniences. This package fills the gaps without compromising simplicity.

What you get**Controllers**JSON / HTML / Twig responses, CORS, annotation-based access control**Models**Fluent query builder, `INSERT ... ON DUPLICATE KEY UPDATE`, helper methods**Utilities**Image/video processing, encryption, CSV, REST client, validation, logging**AWS**Rekognition (face detection &amp; comparison), SES (email delivery)**Scaffold**One command to create a fully working app with auth, dashboard &amp; frontendQuick Start
-----------

[](#quick-start)

```
composer create-project takuya-motoshima/codeigniter-extension myapp
cd myapp
```

Set up permissions and web server:

```
sudo chmod -R 755 public/upload application/{logs,cache,session}
sudo chown -R nginx:nginx public/upload application/{logs,cache,session}
sudo cp nginx.sample.conf /etc/nginx/conf.d/myapp.conf
sudo systemctl restart nginx
```

Import the database and build assets:

```
mysql -u root -p your_database UserModel->get()->result_array();
    parent::set('users', $users)->view('users/index');
  }

  /** @Access(allow_http=true) */
  public function api() {
    parent::set(['message' => 'Success'])->json();
  }
}
```

### Model

[](#model)

```
class UserModel extends AppModel {
  const TABLE = 'user';

  public function getActiveUsers() {
    return $this
      ->where('active', 1)
      ->order_by('name', 'ASC')
      ->get()
      ->result_array();
  }
}
```

### Utilities

[](#utilities)

```
use \X\Util\{ImageHelper, FileHelper, Cipher, RestClient};

// Image
ImageHelper::resize('/path/to/image.jpg', '/path/to/output.jpg', 800, 600);

// Files
FileHelper::makeDirectory('/path/to/dir', 0755);

// Encryption
$encrypted = Cipher::encrypt('secret data', 'encryption-key');

// REST
$client = new RestClient(['base_url' => 'https://api.example.com']);
$response = $client->get('/users');
```

### Twig Templates

[](#twig-templates)

Session variables are automatically available:

```
{% if session.user is defined %}
  Welcome, {{ session.user.name }}!
  {% if session.user.role == 'admin' %}
    Admin Panel
  {% endif %}
{% endif %}
```

API at a Glance
---------------

[](#api-at-a-glance)

**Controller Methods**MethodDescription`json()`Send JSON response`view($template)`Render Twig template`html($html)`Send HTML response`text($text)`Send plain text response`image($path)`Send image response`download($filename, $content)`Force file download`set($key, $value)`Set response data`setCorsHeader($origin)`Set CORS headers**Model Methods**MethodDescription`get_all()`Get all records`get_by_id($id)`Get record by ID`count_by_id($id)`Count records by ID`exists_by_id($id)`Check if record exists`insert_on_duplicate_update()`Upsert single record`insert_on_duplicate_update_batch()`Batch upsert**Utility Classes**ClassKey Methods`ImageHelper``resize()`, `crop()`, `writeDataURLToFile()`, `pdf2Image()``FileHelper``makeDirectory()`, `delete()`, `copyFile()`, `move()``Cipher``encrypt()`, `decrypt()`, `encode_sha256()``RestClient``get()`, `post()`, `put()`, `delete()``Logger``debug()`, `info()`, `error()`, `display()``Validation``hostname()`, `ipaddress()`, `email()`, `is_path()``IpUtils``isIPv4()`, `isIPv6()`, `inRange()``Template``load($template, $params)`Configuration
-------------

[](#configuration)

**Recommended config.php settings**SettingDefaultRecommended`base_url`*empty*Dynamic: `'//' . $_SERVER['HTTP_HOST'] . ...``enable_hooks``FALSE``TRUE``permitted_uri_chars``a-z 0-9~%.:_\-``a-z 0-9~%.:_\-,``sess_save_path``NULL``APPPATH . 'session'``cookie_httponly``FALSE``TRUE``composer_autoload``FALSE``realpath(APPPATH . '../vendor/autoload.php')``index_page``index.php`*empty***Access Control (hooks.php)**```
use \X\Annotation\AnnotationReader;
use \X\Util\Logger;

$hook['post_controller_constructor'] = function() {
  if (is_cli()) return;

  $CI =& get_instance();
  $meta = AnnotationReader::getAccessibility($CI->router->class, $CI->router->method);
  $loggedin = !empty($_SESSION[SESSION_NAME]);

  if (!$meta->allow_http)
    throw new \RuntimeException('HTTP access is not allowed');
  else if ($loggedin && !$meta->allow_login)
    redirect('/users/index');
  else if (!$loggedin && !$meta->allow_logoff)
    redirect('/users/login');
};
```

**Database Session Driver**PHP 7.0+ compatible session handler with custom column support:

```
$config['sess_driver'] = 'database';
$config['sess_save_path'] = 'session';
$config['sess_table_additional_columns'] = ['email'];
```

Implements `updateTimestamp()` to prevent `Failed to write session data` warnings.

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

[](#requirements)

- **PHP** 7.3+
- **Composer**
- **Extensions:** php-gd, php-mbstring, php-xml, php-imagick (optional)

**ImageMagick Installation**Required for `extractFirstFrameOfGif()` in `\X\Util\ImageHelper`.

**Amazon Linux 2:**

```
sudo yum -y install ImageMagick php-imagick
```

**Amazon Linux 2023:**

```
sudo dnf -y install ImageMagick ImageMagick-devel php-pear.noarch
sudo pecl install imagick
echo "extension=imagick.so" | sudo tee -a /etc/php.ini
sudo systemctl restart nginx php-fpm
```

Architecture
------------

[](#architecture)

```
src/X/
├── Annotation/        Access control annotations
├── Composer/          Post-install scaffolding
├── Constant/          Environment & HTTP status constants
├── Controller/        Base controller with response helpers
├── Core/              Extended Loader, Router, URI
├── Database/          Query builder, drivers, result set
├── Exception/         Custom exceptions
├── Hook/              Authentication hook
├── Library/           Form validation, input, session driver
├── Model/             Base model with query helpers
├── Rekognition/       AWS face detection & comparison
└── Util/              21 utility classes

```

Testing
-------

[](#testing)

```
# Run all tests
composer test

# Exclude tests that need AWS credentials or send real email
./vendor/bin/phpunit --exclude-group iam-role,ses-send,assume-role

# Run only IAM role tests (on EC2 with IAM role)
./vendor/bin/phpunit --group iam-role

# Send a real email via SES using explicit credentials
./vendor/bin/phpunit --group ses-send

# Send a real email via SES using cross-account AssumeRole (requires roleArn)
./vendor/bin/phpunit --group assume-role
```

Documentation
-------------

[](#documentation)

- [API Reference](https://shumatsumonobu.github.io/codeigniter-extension/)
- [Demo Application](demo/)
- [Changelog](CHANGELOG.md)
- [CodeIgniter 3 User Guide](https://codeigniter.com/userguide3/)

Troubleshooting
---------------

[](#troubleshooting)

ProblemSolution"Failed to write session data" warningUse `$config['sess_driver'] = 'database'` — the included `SessionDatabaseDriver` handles PHP 7.0+ compatibilityImagick extension not foundInstall ImageMagick + php-imagick (see Requirements)`@Access` annotations ignoredEnable hooks: `$config['enable_hooks'] = TRUE` and configure `hooks.php`Twig templates not updatingClear cache: `rm -rf application/cache/templates/*`Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

Author
------

[](#author)

**shumatsumonobu** — [GitHub](https://github.com/shumatsumonobu) / [Twitter](https://x.com/shumatsumonobu) / [Facebook](https://www.facebook.com/takuya.motoshima.7)

License
-------

[](#license)

[MIT](LICENSE)

###  Health Score

55

—

FairBetter than 97% of packages

Maintenance94

Actively maintained with recent releases

Popularity24

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 96.5% 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 ~6 days

Recently: every ~34 days

Total

447

Last Release

28d ago

Major Versions

v1.3.7 → 2.0.02019-01-13

2.4.2 → 3.0.02019-07-07

3.9.9 → 4.0.02021-05-06

v4.20 → v5.0.02024-05-13

PHP version history (3 changes)v1.0.0PHP ^7.0

v5.0.0PHP ^8.0

v5.0.8PHP ^7.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/31816d7b1852cf712cda71630e28902452d57d3da24726939f9f6188630e5bc2?d=identicon)[shumatsumonobu](/maintainers/shumatsumonobu)

---

Top Contributors

[![shumatsumonobu](https://avatars.githubusercontent.com/u/265669712?v=4)](https://github.com/shumatsumonobu "shumatsumonobu (329 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (10 commits)")[![anil-sc](https://avatars.githubusercontent.com/u/58759296?v=4)](https://github.com/anil-sc "anil-sc (1 commits)")[![ramesh2012](https://avatars.githubusercontent.com/u/16664754?v=4)](https://github.com/ramesh2012 "ramesh2012 (1 commits)")

---

Tags

composercodeigniter

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/takuya-motoshima-codeigniter-extension/health.svg)

```
[![Health](https://phpackages.com/badges/takuya-motoshima-codeigniter-extension/health.svg)](https://phpackages.com/packages/takuya-motoshima-codeigniter-extension)
```

###  Alternatives

[october/rain

October Rain Library

1601.7M103](/packages/october-rain)[abydahana/aksara

Aksara is a modern, developer-friendly framework and CMS built on CodeIgniter 4, featuring rapid CRUD development, modular architecture, smart routing, flexible access control, API integration, and an AI assistant to make content management faster and smarter.

1141.2k](/packages/abydahana-aksara)[sproutcms/cms

Enterprise content management and framework

243.0k4](/packages/sproutcms-cms)

PHPackages © 2026

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