Skip to content

Commit 43b4cf4

Browse files
committed
update
1 parent 348c4c3 commit 43b4cf4

File tree

2 files changed

+116
-44
lines changed

2 files changed

+116
-44
lines changed

04-api.md

Lines changed: 116 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,124 @@ permalink: /api/
55
menu: true
66
---
77

8-
This is a reference of the all global variables and functions.
8+
This is a reference of all global variables and functions.
99

10-
## Standard
10+
## Functions
1111

1212
| Function | Location | Purpose |
1313
| ------------------------------------------- | ------------- | --------------- |
14-
| `e($variable) ` | *.phtml | Output string |
14+
| `e($variable) ` | *.phtml | Output string (escaped) |
1515
| `d($variable) ` | * | Debugging |
16-
| `DB::select($sql,...):array ` | *.php | Database query |
17-
| `DB::selectOne($sql,...):array ` | *.php | Database query |
18-
| `DB::selectValue($sql,...):string ` | *.php | Database query |
19-
| `DB::selectPairs($sql,...):array ` | *.php | Database query |
20-
| `DB::selectValues($sql,...):array ` | *.php | Database query |
21-
| `DB::insert($sql,...):integer ` | *.php | Database query |
22-
| `DB::update($sql,...):integer ` | *.php | Database query |
23-
| `DB::delete($sql,...):integer ` | *.php | Database query |
24-
| `Curl::call($method,$url,$data):array ` | *.php | Curl API call |
25-
| `Curl::navigate($method,$url,$data):array ` | *.php | Curl API call |
26-
| `Auth::login($username,$password):bool ` | *.php | Logging in |
27-
| `Auth::logout():bool ` | *.php | Logging out |
28-
| `Auth::register($username,$password):bool ` | *.php | Adding users |
29-
| `Router::addRoute($req,$loc) ` | routes.php | Routing |
30-
| `Router::redirect($url) ` | *.php | Redirection |
31-
| `Router::json($object) ` | *.phtml | Return JSON |
32-
| `Session::getCsrfInput():string ` | *.phtml | Form security |
33-
34-
## Advanced
35-
36-
| Function | Location | Purpose |
37-
| ------------------------------------------- | ------------- | --------------- |
38-
| `Buffer::set($name,$string) ` | *.php | Set raw HTML |
39-
| `Buffer::get($name):bool ` | *.phtml | Get raw HTML |
40-
| `Buffer::start($name) ` | *.phtml | Nested template |
41-
| `Buffer::end($name) ` | *.phtml | Nested template |
16+
| `t($id,...) ` | * | Translation |
17+
18+
## Database
19+
20+
| Function | Location | Purpose |
21+
| ------------------------------------------- | ------------- | --------------- |
22+
| `DB::select($sql,...):array ` | *.php | Select all rows |
23+
| `DB::selectOne($sql,...):array\|false ` | *.php | Select first row |
24+
| `DB::selectValue($sql,...):mixed ` | *.php | Select single value |
25+
| `DB::selectValues($sql,...):array ` | *.php | Select column values |
26+
| `DB::selectPairs($sql,...):array ` | *.php | Select key-value pairs |
27+
| `DB::insert($sql,...):int ` | *.php | Insert record |
28+
| `DB::update($sql,...):int ` | *.php | Update records |
29+
| `DB::delete($sql,...):int ` | *.php | Delete records |
30+
| `DB::query($sql,...):mixed ` | *.php | Execute query |
31+
| `DB::close():void ` | *.php | Close connection |
32+
33+
## HTTP Client
34+
35+
| Function | Location | Purpose |
36+
| ------------------------------------------- | ------------- | --------------- |
37+
| `Curl::call($method,$url,$data,...):array ` | *.php | HTTP request |
38+
| `Curl::navigate($method,$url,$data,...):array` | *.php | HTTP with redirects |
39+
| `Curl::callCached($exp,$method,$url,...):array` | *.php | Cached HTTP request |
40+
| `Curl::navigateCached($exp,$method,...):array` | *.php | Cached with redirects |
41+
42+
## Authentication
43+
44+
| Function | Location | Purpose |
45+
| ------------------------------------------- | ------------- | --------------- |
46+
| `Auth::login($user,$pass,$totp=''):array ` | *.php | Login user |
47+
| `Auth::logout():bool ` | *.php | Logout user |
48+
| `Auth::register($user,$pass):int ` | *.php | Register user |
49+
| `Auth::update($user,$pass):int ` | *.php | Update password |
50+
| `Auth::updateTotpSecret($user,$secret):int ` | *.php | Enable 2FA |
51+
| `Auth::exists($user):bool ` | *.php | Check user exists |
52+
53+
## Passwordless Auth
54+
55+
| Function | Location | Purpose |
56+
| ------------------------------------------- | ------------- | --------------- |
57+
| `NoPassAuth::token($user):string ` | *.php | Generate login token |
58+
| `NoPassAuth::login($token,$rem=false,...):array` | *.php | Login with token |
59+
| `NoPassAuth::logout():bool ` | *.php | Logout user |
60+
| `NoPassAuth::register($user):int ` | *.php | Register user |
61+
| `NoPassAuth::remember():bool ` | *.php | Restore session |
62+
| `NoPassAuth::update($user):int ` | *.php | Reset password |
63+
| `NoPassAuth::updateTotpSecret($user,$sec):int` | *.php | Enable 2FA |
64+
65+
## Router
66+
67+
| Function | Location | Purpose |
68+
| ------------------------------------------- | ------------- | --------------- |
69+
| `Router::redirect($url,$perm=false):void ` | *.php | Redirect to URL |
70+
| `Router::json($object):void ` | *.php | Output JSON |
71+
| `Router::download($name,$data):void ` | *.php | Download data |
72+
| `Router::file($name,$path):void ` | *.php | Download file |
73+
| `Router::getUrl():string ` | *.php | Get current URL |
74+
| `Router::getBaseUrl():string ` | *.php | Get base URL |
75+
| `Router::getRequest():string ` | *.php | Get request URI |
76+
| `Router::getView():string ` | *.php | Get view path |
77+
| `Router::getAction():string ` | *.php | Get action path |
78+
| `Router::getTemplateView():string ` | *.php | Get template view |
79+
| `Router::getTemplateAction():string ` | *.php | Get template action |
80+
| `Router::getParameters():array ` | *.php | Get URL parameters |
81+
| `Router::getCanonical():string ` | *.php | Get canonical URL |
82+
| `Router::getRedirect():?string ` | *.php | Get redirect URL |
83+
84+
## Session
85+
86+
| Function | Location | Purpose |
87+
| ------------------------------------------- | ------------- | --------------- |
88+
| `Session::getCsrfInput():void ` | *.phtml | Output CSRF field |
89+
| `Session::checkCsrfToken():bool ` | *.php | Verify CSRF token |
90+
| `Session::start():void ` | *.php | Start session |
91+
| `Session::end():void ` | *.php | End session |
92+
| `Session::regenerate():void ` | *.php | Regenerate session |
93+
94+
## Buffer
95+
96+
| Function | Location | Purpose |
97+
| ------------------------------------------- | ------------- | --------------- |
98+
| `Buffer::start($name):void ` | *.phtml | Start buffer |
99+
| `Buffer::end($name):void ` | *.phtml | End buffer |
100+
| `Buffer::set($name,$string):void ` | *.php | Set buffer content |
101+
| `Buffer::get($name):bool ` | *.phtml | Output buffer |
102+
103+
## Cache
104+
105+
| Function | Location | Purpose |
106+
| ------------------------------------------- | ------------- | --------------- |
107+
| `Cache::get($key):mixed ` | *.php | Get cached value |
108+
| `Cache::set($key,$val,$exp=0):bool ` | *.php | Set cache value |
109+
| `Cache::delete($key):bool ` | *.php | Delete from cache |
110+
| `Cache::add($key,$val,$exp=0):bool ` | *.php | Add if not exists |
111+
| `Cache::replace($key,$val,$exp=0):bool ` | *.php | Replace if exists |
112+
| `Cache::increment($key,$val=1):int\|false ` | *.php | Increment value |
113+
| `Cache::decrement($key,$val=1):int\|false ` | *.php | Decrement value |
114+
115+
## Internationalization
116+
117+
| Function | Location | Purpose |
118+
| ------------------------------------------- | ------------- | --------------- |
119+
| `I18n::translate($id):string ` | *.php | Translate string |
120+
| `I18n::price($val,$min=2,$max=2):string ` | *.php | Format price |
121+
| `I18n::currency($val,$min=2,$max=2):string ` | *.php | Format currency |
122+
| `I18n::date($str):string ` | *.php | Format date |
123+
| `I18n::datetime($str):string ` | *.php | Format datetime |
124+
| `I18n::time($h,$m,$s=0):string ` | *.php | Format time |
125+
| `I18n::duration($sec,$trim=false):string ` | *.php | Format duration |
126+
| `I18n::weekDay($day):string ` | *.php | Get weekday name |
127+
| `I18n::monthName($month):string ` | *.php | Get month name |
128+
| `I18n::datetimeShort($str):string ` | *.php | Format datetime short |

docs/router.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -206,18 +206,3 @@ Example:
206206
```
207207
$redirect = Router::getRedirect();
208208
```
209-
210-
## Apply Routes
211-
212-
```
213-
Router::applyRoutes(): void
214-
```
215-
216-
Apply route mappings to the current request. Typically called from `config/router.php`.
217-
218-
Example:
219-
220-
```
221-
Router::$routes = ['/' => 'home'];
222-
Router::applyRoutes();
223-
```

0 commit comments

Comments
 (0)