takuya-motoshima / codeigniter-extension
Extend CodeIgniter for ease of use
Installs: 5 059
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 3
Forks: 4
Language:JavaScript
pkg:composer/takuya-motoshima/codeigniter-extension
Requires
- php: ^8.0
- ext-openssl: *
- aws/aws-sdk-php: ^3.64
- codeigniter/framework: 3.1.*
- doctrine/common: ^2.10
- hybridauth/hybridauth: 2.*
- intervention/image: ^2.5
- mathieuviossat/arraytotexttable: ^1.0
- twig/twig: 2.*
- vlucas/phpdotenv: ^5.3
Requires (Dev)
- codedungeon/phpunit-result-printer: ^0.32.0
- phpunit/phpunit: ^8.4
- dev-main
- 5.0.2
- 5.0.1
- 5.0.0
- 4.20
- 4.1.9
- 4.1.8
- 4.1.7
- 4.1.6
- 4.1.5
- 4.1.4
- 4.1.3
- 4.1.2
- 4.1.1
- 4.1.0
- 4.0.25
- 4.0.24
- 4.0.23
- 4.0.22
- 4.0.21
- 4.0.20
- 4.0.19
- 4.0.18
- 4.0.17
- 4.0.16
- 4.0.15
- 4.0.14
- 4.0.13
- 4.0.12
- 4.0.11
- 4.0.10
- 4.0.9
- 4.0.8
- 4.0.7
- 4.0.6
- 4.0.5
- 4.0.4
- 4.0.3
- 4.0.2
- 4.0.1
- 4.0.0
- 3.9.9
- 3.9.8
- 3.9.7
- 3.9.6
- 3.9.5
- 3.9.4
- 3.9.3
- 3.9.2
- 3.9.1
- 3.9.0
- 3.8.9
- 3.8.8
- 3.8.7
- 3.8.6
- 3.8.5
- 3.8.4
- 3.8.3
- 3.8.2
- 3.8.1
- 3.8.0
- 3.7.9
- 3.7.8
- 3.7.7
- 3.7.6
- 3.7.5
- 3.7.4
- 3.7.3
- 3.7.2
- 3.7.1
- 3.7.0
- 3.6.9
- 3.6.8
- 3.6.7
- 3.6.6
- 3.6.5
- 3.6.4
- 3.6.3
- 3.6.2
- 3.6.1
- 3.6.0
- 3.5.9
- 3.5.8
- 3.5.7
- 3.5.6
- 3.5.5
- 3.5.4
-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 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-dependabot/npm_and_yarn/demo/client/axios-1.12.2
This package is auto-updated.
Last update: 2025-11-08 01:17:06 UTC
README
An enhanced CodeIgniter 3 package providing extended core classes (controllers, models, views) and utility classes.
Table of Contents
- Features
- Requirements
- Installation
- Quick Start
- Configuration
- Usage Examples
- Testing
- Documentation
- License
Features
Core Extensions
- Enhanced Controllers - JSON response, template rendering, access control
- Advanced Models - Query caching, batch operations, helper methods
- Enhanced Router - Annotation-based access control
Utility Classes
- Image Processing - Resize, crop, format conversion, GIF frame extraction, PDF to image
- Video Processing - Video file manipulation and conversion
- File Operations - Advanced file and directory operations with locking
- CSV Handling - Import/export utilities
- Email - Template-based emails, Amazon SES integration
- REST Client - HTTP client for API integrations
- Security - Encryption/decryption, IP validation
- Validation - Custom rules (hostname, IP, CIDR, datetime, paths)
- Session Management - Database-backed sessions with custom columns
- Logging - Enhanced logging with context
- Template Engine - Twig integration with session variables
AWS Integration
- Amazon Rekognition - Face detection, comparison, and analysis
- Amazon SES - Reliable email delivery service
Requirements
- PHP 7.3.0 or later
- Composer
- PHP Extensions:
- php-gd
- php-mbstring
- php-xml
- php-imagick (optional, for GIF operations)
Optional: ImageMagick Installation
Required for extractFirstFrameOfGif method in \X\Util\ImageHelper.
Amazon Linux 2:
sudo yum -y install ImageMagick php-imagick
Amazon Linux 2023:
# Install ImageMagick and PECL sudo dnf -y install ImageMagick ImageMagick-devel php-pear.noarch # Install imagick extension sudo pecl install imagick echo "extension=imagick.so" | sudo tee -a /etc/php.ini # Restart services sudo systemctl restart nginx php-fpm
Installation
Create a new project using Composer:
composer create-project takuya-motoshima/codeigniter-extension myapp
cd myapp
Quick Start
1. Set Permissions
sudo chmod -R 755 public/upload application/{logs,cache,session}
sudo chown -R nginx:nginx public/upload application/{logs,cache,session}
2. Configure Web Server
Copy the Nginx configuration:
sudo cp nginx.sample.conf /etc/nginx/conf.d/myapp.conf sudo systemctl restart nginx
3. Set Up Database
Import the database schema:
mysql -u root -p your_database < skeleton/init.sql
4. Build Frontend Assets
cd client
npm install
npm run build
5. Access Application
Open http://{your-server-ip}:3000/ in your browser.
Default Credentials:
- Email:
robin@example.com - Password:
password
Screenshots
Configuration
Basic Config (application/config/config.php)
| Setting | Default | Recommended |
|---|---|---|
| base_url | empty | if (!empty($_SERVER['HTTP_HOST'])) $config['base_url'] = '//' . $_SERVER['HTTP_HOST'] . str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); |
| 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 Setup
1. Define Default Route
In application/config/routes.php:
$route['default_controller'] = 'users/login';
2. Set Session Constant
In application/config/constants.php:
const SESSION_NAME = 'session';
3. Configure Hooks
In application/config/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'); }; $hook['pre_system'] = function () { $dotenv = Dotenv\Dotenv::createImmutable(ENV_DIR); $dotenv->load(); set_exception_handler(function ($e) { Logger::error($e); show_error($e->getMessage(), 500); }); };
Usage Examples
Controllers
use \X\Annotation\Access; class Users extends AppController { /** * @Access(allow_login=true, allow_logoff=false, allow_role="admin") */ public function index() { $users = $this->UserModel->get()->result_array(); parent::set('users', $users)->view('users/index'); } /** * @Access(allow_http=true) */ public function api() { $data = ['message' => 'Success']; parent::set($data)->json(); } }
Models
class UserModel extends AppModel { const TABLE = 'user'; public function getActiveUsers() { return $this ->where('active', 1) ->order_by('name', 'ASC') ->get() ->result_array(); } }
Twig Templates
Session variables are automatically available:
// PHP $_SESSION['user'] = ['name' => 'John Smith', 'role' => 'admin'];
{# Template #} {% if session.user is defined %} <p>Welcome, {{ session.user.name }}!</p> {% if session.user.role == 'admin' %} <a href="/admin">Admin Panel</a> {% endif %} {% endif %}
Using Utilities
// Image processing use \X\Util\ImageHelper; ImageHelper::resize('/path/to/image.jpg', '/path/to/output.jpg', 800, 600); // File operations use \X\Util\FileHelper; FileHelper::makeDirectory('/path/to/dir', 0755); // Encryption use \X\Util\Cipher; $encrypted = Cipher::encrypt('secret data', 'encryption-key'); // REST client use \X\Util\RestClient; $client = new RestClient(['base_url' => 'https://api.example.com']); $response = $client->get('/users');
Testing
Run unit tests:
composer test
Test files are located in:
__tests__/*.php- Test casesphpunit.xml- Configurationphpunit-printer.yml- Output format
Documentation
- API Documentation - Complete API reference
- Demo Application - Full working example
- Changelog - Version history and changes
- CodeIgniter 3 Guide - Official framework documentation
Generate PHPDoc
# Download phpDocumentor (one-time) wget https://phpdoc.org/phpDocumentor.phar chmod +x phpDocumentor.phar # Generate docs php phpDocumentor.phar run -d src/ --ignore vendor --ignore src/X/Database/Driver/ -t docs/
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Author
Takuya Motoshima
- GitHub: @takuya-motoshima
- Twitter: @TakuyaMotoshima
- Facebook: takuya.motoshima.7

