appkita/ci4restfull-starter
Composer 安装命令:
composer create-project appkita/ci4restfull-starter
包简介
CodeIgniter4 starter Restfull API
README 文档
README
CodeIgniter 4 Restfull API Application Starter
Codeigniter 4 Restfull is the creation of Restfull API with the codeigniter 4 framework. Use is very simple and easy to use. And support with 4 types of security authentication ex. JWT, Basic, Key, Token
You can manage api using database or File configuration
follow Setup Configuration!
Chat
Installation & updates
- composer
composer create-project appkita/ci4restfull-starter
cd ci4restfull-starter
composer update
-manual
- Download latest release from
https://github.com/gunantos/ci4restfull-starter/releases - extract to public_html
composer install
Setup
- Copy
envto.envand tailor for your app, specifically the baseURL, any database settings and Restfull setting.
or
- Open Folder
App/Config/Restfulland edit
//you can set database of file public $cekfrom = 'file' //configuration user cek public $user_config = [ 'model' => 'UserModel', //model name or parameter if you using file 'username_coloumn'=>'email', 'password_coloumn'=>'password', 'key_coloumn' => 'apikey', 'path_coloumn'=>'path', 'block_coloumn'=>'isblock', 'whitelist_coloumn'=>'whitelist', 'blacklist_coloumn'=>'blacklist' ]; //if you using file $cekfrom $UserModel = [ [ 'email'=>'user@email.com', 'password'=>'password', 'apikey'=>'123123', 'isblock'=>false, //if you block return true 'whitelist'=>[], //add whitelist ip address 'blacklist'=>[], //add blacklist ip address 'path'=>'*' //use * for allow all access or array controllername_methodname ] ] //Configuration your Header API KEY public $haderKey = 'X-API-KEY'; /** * @var array $allowed_key_parameter * if you API KEY allowed get from parameter GET, POST, or JSON */ public $allowed_key_parameter = ['get', 'post', 'json']; //configuration data include on json token $token_data = 'username'; public $allowed_format = ['json', 'xml', 'csv']; /** * @var string $default_format */ public $default_format = 'json';
- Create new Controller extends
RestfullApi
<?php namespace App\Controllers; use \Appkita\CI4Restfull\RestfullApi; use \App\Models\UserModel; class Home extends RestfullApi { #protected $modelName = 'UserModel'; protected $model; protected $allowed_format = ['json']; protected $auth = ['key']; function __construct() { $this->model = new UserModel(); } public function index() { return $this->respond(['status'=>true, 'data'=>$this->model->findAll()]); } public function show($id = null) { return $this->respond(['status'=>true, 'data'=>$this->model->find($id)]); } public function create() { die('create '); } public function update($id = null) { die('update '. $id); } public function deleted($id = null) { die('deleted '. $id); } }
- Run application with
sparkorhost
//spark php spark serve
- acess api
http://localhost:8080spark runhttp://localhost/yourapi/publicxamp or wamp
Important
Please read the user guide of Codeigniter 4
Sponsor
appkita/ci4restfull-starter 适用场景与选型建议
appkita/ci4restfull-starter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 98 次下载、GitHub Stars 达 18, 最近一次更新时间为 2021 年 05 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 appkita/ci4restfull-starter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 appkita/ci4restfull-starter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 98
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 18
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-05-10