-
Notifications
You must be signed in to change notification settings - Fork 1
/
AbstractConfig.php
52 lines (50 loc) · 1.72 KB
/
AbstractConfig.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* Configuration to be used across other parts.
* ```php
* //usage
* class config extends AbstractConfig{
* static $secret= 'SECRET'; // required
* //similary custom data, if needed.
* }
* $config= new config(); // throws error if not `$secret`, see above
* ```
* You can also edit odthers main keys (e. g. `$expiration`).
* */
abstract class AbstractConfig{
/** @var str Main api URL access point */
public $api_url= '../api';
/** @var str Secret argument for JWT */
public $secret;
/** @var int Expiration time in seconds for JWT */
public $expiration= 3600;
/**
* Use following `.htaccess`:
* ```text
* main_folder/
* index.php //main API file
* .htaccess
* this_file_folder/
*
* .htaccess
* RewriteEngine on
* RewriteRule ^(.*[^/\?])/?(\??.*) index.php?__target=$1&$2 [QSA,L]
* ```
* @var str Name of the GET key where the requested uri is stored (`/…/path/…` → `?__target=…/path/…` via `.htaccess`)
* */
public $path_key= '__target';
/** @var string The name of the folder for processing requests with record ID. */
public $path_id= ':id';
/** @var str Endpoint for Authentication based on your Authorization class. */
public $auth_path= 'auth';
/** @var str Information for auth documentation, where to get typically `client_secret`. */
public $auth_emails= '[email protected]';
/** @var str[] Supported API versions and their order. */
public $versions= array();
public function sqlSelectId($column= 'id', $as= 'id'){ return "$column*8+5 AS $as"; }
public function sqlWhereId($column= 'id'){ return "$column*8+5"; }
public function __construct(){
if(!$this->secret) throw new \InvalidArgumentException('Please set `Config::$secret`!');
return $this;
}
}