1. Go to this page and download the library: Download appkita/ci4restfull-starter library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
appkita / ci4restfull-starter example snippets
//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
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);
}
}
sh
//spark
php spark serve
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.