Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gunantos/ci4restfull-starter
Create simple Restfull Api With Codeigniter 4 Framework
https://github.com/gunantos/ci4restfull-starter
api codeigniter4 database php phpauthentication rest-api restfull-api
Last synced: 3 months ago
JSON representation
Create simple Restfull Api With Codeigniter 4 Framework
- Host: GitHub
- URL: https://github.com/gunantos/ci4restfull-starter
- Owner: gunantos
- License: mit
- Created: 2021-05-10T15:02:17.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-08-15T05:36:47.000Z (over 3 years ago)
- Last Synced: 2024-10-01T00:41:22.292Z (3 months ago)
- Topics: api, codeigniter4, database, php, phpauthentication, rest-api, restfull-api
- Language: PHP
- Homepage: https://gunantos.github.io/ci4restfull-starter/
- Size: 183 KB
- Stars: 16
- Watchers: 1
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
[![PHP Composer](https://github.com/gunantos/ci4restfull-starter/actions/workflows/php.yml/badge.svg)](https://github.com/gunantos/ci4restfull-starter/actions/workflows/php.yml)
![Discord](https://img.shields.io/discord/846036920811126844?style=plastic)
[![GitHub issues](https://img.shields.io/github/issues/gunantos/ci4restfull-starter)](https://github.com/gunantos/ci4restfull-starter/issues)
[![GitHub license](https://img.shields.io/github/license/gunantos/ci4restfull-starter)](https://github.com/gunantos/ci4restfull-starter/blob/main/LICENSE)
# CodeIgniter 4 Restfull API Application StarterCodeigniter 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
[Discord](https://discord.gg/bXUWCSaw)## Installation & updates
- composer
```sh
composer create-project appkita/ci4restfull-starter
cd ci4restfull-starter
composer update
```-manual
1. Download latest release from `https://github.com/gunantos/ci4restfull-starter/releases`
2. extract to public_html
3. `composer install`## Setup
- Copy `env` to `.env` and tailor for your app, specifically the baseURL, any database settings and Restfull setting.
`or`
- Open Folder `App/Config/Restfull` and edit
```php
//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'=>'[email protected]',
'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
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 `spark` or `host`
```sh
//spark
php spark serve
```- acess api
`http://localhost:8080` spark run
`http://localhost/yourapi/public` xamp or wamp## Important
**Please** read the user guide of [Codeigniter 4](https://codeigniter.com/user_guide/)
# Sponsor
[Pay Coffe](https://sponsor.app-kita.net)