nguyenanhung / codeigniter-framework
The CodeIgniter Framework - v3.2.0
Installs: 6 511
Dependents: 5
Suggesters: 0
Security: 0
Stars: 5
Watchers: 2
Forks: 4
Open Issues: 0
Requires
- php: >=5.6
- ext-json: *
- nguyenanhung/codeigniter-basic-helper: >=1.0
- symfony/polyfill-mbstring: >=1.0
Requires (Dev)
- nguyenanhung/my-debug: ^4.0 || ^3.0 || ^2.0 || ^1.0
Suggests
- nguyenanhung/basic-firewall: PHP Basic Firewall - Library providing IP filtering features
- nguyenanhung/database: Need support for Powerful SQL Database Tools (Customize Laravel Database)
- nguyenanhung/helpers: Awesome Helpers - Powerful Library, Helpers and Tools
- nguyenanhung/image: Need support for Image Service
- nguyenanhung/markdown: Parser for Markdown
- nguyenanhung/monitor: Need support for Send Monitor Message to Monitor Service
- nguyenanhung/my-cache: Need support for Powerful Cache Implement
- nguyenanhung/my-debug: Need support for Powerful Logger (Extend from Monolog)
- nguyenanhung/requests: Need support for Powerful HTTP Request
- nguyenanhung/security: Awesome Helpers - Wrapper for Security, Encrypt, Encode, Purifier
- nguyenanhung/seo: Need support for SEO
- nguyenanhung/validation: Awesome Validation - A fast, extensible & stand-alone PHP input validation class that allows you to validate any data
- dev-master
- v3.2.0.39
- v3.2.0.38
- v3.2.0.37
- v3.2.0.36
- v3.2.0.35
- v3.2.0.34
- v3.2.0.33
- v3.2.0.32
- v3.2.0.31
- v3.2.0.30
- v3.2.0.29
- v3.2.0.28
- v3.2.0.27
- v3.2.0.26
- v3.2.0.25
- v3.2.0.24
- v3.2.0.23
- v3.2.0.22
- v3.2.0.21
- v3.2.0.20
- v3.2.0.19
- v3.2.0.18
- v3.2.0.17
- v3.2.0.16
- v3.2.0.15
- v3.2.0.14
- v3.2.0.13
- v3.2.0.12
- v3.2.0.11
- v3.2.0.10
- v3.2.0.9
- v3.2.0.8
- v3.2.0.7
- v3.2.0.6
- v3.2.0.5
- v3.2.0.4
- v3.2.0.3
- v3.2.0.2
- v3.2.0.1
- v3.2.0
- v3.1.15.14
- v3.1.15.13
- v3.1.15.12
- v3.1.15.11
- v3.1.15.10
- v3.1.15.9
- v3.1.15.8
- v3.1.15.7
- v3.1.15.6
- v3.1.15.5
- v3.1.15.4
- v3.1.15.3
- v3.1.15.2
- v3.1.15.1
- v3.1.15
- v3.1.14.21
- v3.1.14.20
- v3.1.14.19
- v3.1.14.18
- v3.1.14.17
- v3.1.14.16
- v3.1.14.15
- v3.1.14.14
- v3.1.14.13
- v3.1.14.12
- v3.1.14.11
- v3.1.14.10
- v3.1.14.9
- v3.1.14.8
- v3.1.14.7
- v3.1.14.6
- v3.1.14.5
- v3.1.14.4
- v3.1.14.3
- v3.1.14.2
- v3.1.14.1
- v3.1.14
- v3.1.13.21
- v3.1.13.20
- v3.1.13.19
- v3.1.13.18
- v3.1.13.17
- v3.1.13.16
- v3.1.13.15
- v3.1.13.14
- v3.1.13.13
- v3.1.13.12
- v3.1.13.11
- v3.1.13.10
- v3.1.13.9
- v3.1.13.8
- v3.1.13.7
- v3.1.13.6
- v3.1.13.5
- v3.1.13.4
- v3.1.13.3
- v3.1.13.2
- v3.1.13.1
- v3.1.13
- v3.1.12.11
- v3.1.12.10
- v3.1.12.9
- v3.1.12.8
- v3.1.12.7
- v3.1.12.6
- v3.1.12.5
- v3.1.12.4
- v3.1.12.3
- v3.1.12.2
- v3.1.12.1
- v3.1.12
- v3.1.11.15
- v3.1.11.14
- v3.1.11.13
- v3.1.11.12
- v3.1.11.11
- v3.1.11.10
- v3.1.11.9
- v3.1.11.8
- v3.1.11.7
- v3.1.11.6
- v3.1.11.5
- v3.1.11.4
- v3.1.11.3
- v3.1.11.2
- v3.1.11.1
- v3.1.11
- dev-v3.2.0-develop
- dev-v3.1-stable
This package is auto-updated.
Last update: 2025-03-14 18:33:48 UTC
README
Repackaged version of CodeIgniter's system framework, compatible with Composer and PHP 7, PHP 8
Since version v3.2.0
- the framework is fully compatible with PHP 8.2
This package is constantly updated with new features from the original CodeIgniter3 branch. So it is always updated with bug fixes and added new features
Main features
Added some extension libraries, related helpers
- Base Controllers with many available protected methods
- Support HMVC model
- Support RESTful Web Service
- Support Queue Worker
- Support MongoDB database
- Support Elasticsearch: Use third party packages
"elasticsearch/elasticsearch": "^8.0 || ^7.0 || ^6.0 || ^5.0"
- Support Base Model class with some basic functions enough for SQL
- Support ORM Model class, providing a simpler and easier method to query
- Support Output Response on CLI interface via function
ResponseOutput::writeLn($message)
- Added
StatusCodes
class to declare standard HTTP codes (from Symfony framework), For example:StatusCodes::HTTP_OK
. For more details, please refer to classStatusCodes
- Add many useful helpers with the built-in package
nguyenanhung/codeigniter-basic-helper
via Composer
Instructions for installing packages into the project
- Install the package into the project with the following command
composer require nguyenanhung/codeigniter-framework
- Update the
index.php
file
Find the line
/* *--------------------------------------------------------------- * SYSTEM DIRECTORY NAME *--------------------------------------------------------------- * * This variable must contain the name of your "system" directory. * Set the path if it is not in the same directory as this file. */ $system_path = 'system';
Edit as follows
/* *--------------------------------------------------------------- * SYSTEM DIRECTORY NAME *--------------------------------------------------------------- * * This variable must contain the name of your "system" directory. * Set the path if it is not in the same directory as this file. */ $system_path = '/your_vendor_path/nguyenanhung/codeigniter-framework/system';
- Delete the
system
folder in the project root folder for neatness
User guide
Instructions for writing a Controller that inherits a Base Controller
In the library, there is a built-in Base Controller, inherit as follows
- Build a new
Controller
according to the CodeIgniter 3 documentation - Inherit the class from
HungNG_CI_Base_Controllers
instead ofCI_Controller
, for example as follows
<?php /** * Class Hungna_test * * @author 713uk13m <dev@nguyenanhung.com> * @copyright 713uk13m <dev@nguyenanhung.com> */ class Hungna_test extends HungNG_CI_Base_Controllers { public function __construct() { parent::__construct(); } public function index() { echo "This is ".get_class($this); // show: This is Hungna_test exit(); } }
Instructions for writing a Controller that runs a Queue Worker
In the library, there is a built-in Base Queue Worker (built by yidas), inherit as follows
- Build a new
Controller
according to the CodeIgniter 3 documentation - Inherit the class from
HungNG_CI_Base_Queue_Worker
instead ofCI_Controller
, for example as follows
<?php /** * Class My_worker * * @author 713uk13m <dev@nguyenanhung.com> * @copyright 713uk13m <dev@nguyenanhung.com> */ class My_worker extends HungNG_CI_Base_Queue_Worker { // Initializer protected function init() {} // Worker protected function handleWork() {} // Listener protected function handleListen() {} }
Learn more details in the documentation here: https://github.com/nguyenanhung/codeigniter-framework-sample/tree/main/codeigniter-queue-worker
Instructions for writing a Controller to run RESTful API Service
In the library, there is a pre-built RESTful Base (built by yidas), inherit as follows
- Build a new
Controller
according to the CodeIgniter 3 documentation - Inherit the class from
HungNG_CI_Base_REST
instead ofCI_Controller
, for example as follows
<?php /** * Class My_rest_api * * @author 713uk13m <dev@nguyenanhung.com> * @copyright 713uk13m <dev@nguyenanhung.com> */ class My_rest_api extends HungNG_CI_Base_REST { public function index() { return $this->response->json(['bar'=>'foo']); } public function store($requestData=null) { $this->db->insert('mytable', $requestData); $id = $this->db->insert_id(); return $this->response->json(['id'=>$id], 201); } }
Learn more details in the documentation here: https://github.com/nguyenanhung/codeigniter-framework-sample/tree/main/codeigniter-rest
Instructions for writing a Model that inherits Base Model
- Build a model according to the CodeIgniter 3 documentation
- Inherit the class from
HungNG_Custom_Based_model
instead ofCI_Model
, for example as follows
<?php defined('BASEPATH') or exit('No direct script access allowed'); /** * Class Credentials_model * * @author 713uk13m <dev@nguyenanhung.com> * @copyright 713uk13m <dev@nguyenanhung.com> * @property \CI_DB_query_builder $db */ class Credentials_model extends HungNG_Custom_Based_model { const IS_ACTIVE = 1; const ROLE_PUSH = 1; const ROLE_PULL = 2; const ROLE_FULL = 3; protected $fieldUsername; protected $fieldStatus; protected $fieldRole; /** * Credentials_model constructor. * * @author : 713uk13m <dev@nguyenanhung.com> * @copyright: 713uk13m <dev@nguyenanhung.com> */ public function __construct() { parent::__construct(); $this->db = $this->load->database('default', true, true); $this->tableName = 'credentials'; $this->primary_key = 'id'; $this->fieldUsername = 'username'; $this->fieldStatus = 'status'; $this->fieldRole = 'role'; } }
How to write a Model that inherits the Base ORM Model
- This package adds a modern way to write models in ORM style with Elegant patterns like Laravel Eloquent ORM & Yii2 Active Record (built by yidas)
- Read detailed documentation on how to integrate and deploy here with visual and specific examples: https://github.com/nguyenanhung/codeigniter-framework-sample/tree/main/codeigniter-orm-model
Basic SEO Integration Guide
-
This package adds a simple SEO library and helper
-
Read detailed documentation on how to integrate and deploy here with visual and specific examples: https://github.com/nguyenanhung/codeigniter-framework-sample/blob/main/codeigniter3-basic-seo/README.md
Instructions for using MongoDB database in the project
- By default, CodeIgniter v3 does not support MongoDB. However, that is not a limitation, CodeIgniter is an open framework, so I have added a library to support calling, interacting, and processing with MongoDB database, which is also quite similar to CodeIgniter 2's Query Builder. Read detailed documentation on how to integrate and deploy here with intuitive and specific examples: https://github.com/nguyenanhung/codeigniter-framework-sample/tree/main/codeigniter-mongodb
Instructions for using Elasticsearch in the project
- By default, CodeIgniter v3 does not support Elasticsearch. However, that does not limit it, CodeIgniter is an open framework, so I have added a library to support calling and interacting with Elasticsearch
- Read detailed documentation on how to integrate and deploy here with intuitive and specific examples: https://github.com/nguyenanhung/codeigniter-framework-sample/tree/main/codeigniter-elasticsearch
Instructions for integrating HMVC model into the project
- Create folder:
modules
in theapplication
folder. Refer to themodules-samples
folder structure at https://github.com/nguyenanhung/codeigniter-framework-sample/tree/main/modules-sample
.
└── modules
└── startup
├── config
│ ├── index.html
│ └── routes.php
├── controllers
│ ├── Startup.php
│ └── index.html
├── index.html
├── models
│ ├── Startup_model.php
│ └── index.html
└── views
└── index.html
6 directories, 8 files
- Create file
hmvc.php
with the following content
<?php defined('BASEPATH') or exit('No direct script access allowed'); /* | ------------------------------------------------------------------------- | HMVC settings | ------------------------------------------------------------------------- | See: https://github.com/nguyenanhung/CodeIgniter-HMVC | */ $config['modules_locations'] = array( APPPATH . 'modules/' => '../modules/' );
- Load the
hmvc.php
file into theconfig.php
file
require_once __DIR__ . '/hmvc.php';
- Create file
MY_Loader.php
in folderapplication/core/
with following content
<?php defined('BASEPATH') or exit('No direct script access allowed'); /** * Class MY_Loader * * @author 713uk13m <dev@nguyenanhung.com> * @copyright 713uk13m <dev@nguyenanhung.com> */ class MY_Loader extends HungNG_Loader { }
- Create file
MY_Router.php
in folderapplication/core/
with following content
<?php defined('BASEPATH') or exit('No direct script access allowed'); /** * Class MY_Router * * @author 713uk13m <dev@nguyenanhung.com> * @copyright 713uk13m <dev@nguyenanhung.com> */ class MY_Router extends HungNG_Router { }
- Deploy the code in the new modules folder, similar to the following
<?php defined('BASEPATH') or exit('No direct script access allowed'); /** * Class TestModule * * @author 713uk13m <dev@nguyenanhung.com> * @copyright 713uk13m <dev@nguyenanhung.com> */ class TestModule extends HungNG_CI_Base_Module { public function __construct() { parent::__construct(); } public function index() { echo "This is ".get_class($this); // show: This is TestModule exit(); } }
How to check if the filenames in your project are up to CodeIgniter standards
-
This controller checks CodeIgniter 3.0 class filename.
-
Read detailed documentation on how to integrate and deploy here with visual and specific examples: https://github.com/nguyenanhung/codeigniter-framework-sample/tree/main/codeigniter3-filename-checker
Instructions for logging all queries in CodeIgniter and recording the Execution Time of each Queries
-
By default, CodeIgniter v3 does not support logging the Execution Time of Queries. However, you can use Hooks to do this
-
Read the detailed documentation on how to integrate and deploy here with visual and specific examples: https://github.com/nguyenanhung/codeigniter-framework-sample/tree/main/codeigniter-log-all-queries
CodeIgniter Basic Helper
- Over the years of programming with CodeIgniter, I have collected, built and written quite a few helpers, I have
packaged
them into the package
nguyenanhung/codeigniter-basic-helper
and integrated them into this package. - This helper package is still being operated and developed by me every day, the number of projects integrating the functions in this package has reached thousands
- More detailed information about this helper set https://github.com/nguyenanhung/codeigniter-basic-helper
Contact Information
Name | Skype | Website | ||
---|---|---|---|---|
Hung Nguyen | dev@nguyenanhung.com | nguyenanhung5891 | @nguyenanhung | https://nguyenanhung.com |