承接 nguyenanhung/codeigniter-framework 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nguyenanhung/codeigniter-framework

Composer 安装命令:

composer require nguyenanhung/codeigniter-framework

包简介

The CodeIgniter Framework - v3.2.0

README 文档

README

Latest Stable Version Total Downloads Daily Downloads Monthly Downloads License PHP Version Require

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 class StatusCodes
  • Add many useful helpers with the built-in package nguyenanhung/codeigniter-basic-helper via Composer

Instructions for installing packages into the project

  1. Install the package into the project with the following command
composer require nguyenanhung/codeigniter-framework
  1. 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';
  1. 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

  1. Build a new Controller according to the CodeIgniter 3 documentation
  2. Inherit the class from HungNG_CI_Base_Controllers instead of CI_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

  1. Build a new Controller according to the CodeIgniter 3 documentation
  2. Inherit the class from HungNG_CI_Base_Queue_Worker instead of CI_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

  1. Build a new Controller according to the CodeIgniter 3 documentation
  2. Inherit the class from HungNG_CI_Base_REST instead of CI_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

  1. Build a model according to the CodeIgniter 3 documentation
  2. Inherit the class from HungNG_Custom_Based_model instead of CI_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

  1. 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)
  2. 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

  1. This package adds a simple SEO library and helper

  2. 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

  1. 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

  1. 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
  2. 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

  1. Create folder: modules in the application folder. Refer to the modules-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
  1. 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/'
);
  1. Load the hmvc.php file into the config.php file
require_once __DIR__ . '/hmvc.php';
  1. Create file MY_Loader.php in folder application/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
{

}
  1. Create file MY_Router.php in folder application/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
{

}
  1. 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

  1. This controller checks CodeIgniter 3.0 class filename.

  2. 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

  1. By default, CodeIgniter v3 does not support logging the Execution Time of Queries. However, you can use Hooks to do this

  2. 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 Email Skype Facebook Website
Hung Nguyen dev@nguyenanhung.com nguyenanhung5891 @nguyenanhung https://nguyenanhung.com

nguyenanhung/codeigniter-framework 适用场景与选型建议

nguyenanhung/codeigniter-framework 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.71k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2020 年 12 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 nguyenanhung/codeigniter-framework 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nguyenanhung/codeigniter-framework 我们能提供哪些服务?
定制开发 / 二次开发

基于 nguyenanhung/codeigniter-framework 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 6.71k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 0
  • 依赖项目数: 5
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 2
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-12-05