Standard Library
Zymba provides a rich set of built-in static classes accessed with the @ prefix. This chapter covers every built-in class with verified examples.
Class overview
| Class | Methods | Purpose |
|---|---|---|
@String | 96 | String manipulation — trim, replace, split, case, search |
@Regex | 11 | Regular expression testing, matching, and replacing |
@Math | 62 | Mathematical functions — trig, log, rounding, random |
@Number | 42 | Number formatting, type checks, base conversion, rounding |
@Statistic | 29 | Statistical analysis — mean, median, mode, variance |
@Date | 31 | Date/time — now, format, parse, components, timezone |
@Var | 30 | JSON/PHP serialization, type inspection, cloning |
@URI | 20 | URL encoding/decoding, query strings, parsing |
@MIME | 12 | Base64 and MIME encoding |
@ZLIB | 6 | Compression: deflate, inflate, gzip |
@XML | 5 | XML parsing and generation |
@IO | 61 | File, directory, and stream operations |
@HTTP | 42 | HTTP client/server — requests, headers, cookies |
@DNS | 7 | DNS resolution and validation |
@Path | 15 | File path manipulation |
@System | 8 | System info: host, PID, memory usage |
@Console | 7 | Logging and debug output |
@Output | 6 | Output buffering control |
@Crypt | 22 | Hashing, encryption, JWT, UUID generation |
@Exception | — | Exception creation and stack traces |
@Function | 7 | Function introspection and reflection |
@Array | 97 | Array manipulation (covered in Arrays and Collections) |
@SQL | 4 | SQL query preparation (covered in Platform Integration) |
@ZeyOS | 16 | Platform integration (covered in Platform Integration) |
Practical patterns
JSON API response handler
ZYMBA
function $apiRequest($url, $method = "GET", $data = null) {
$headers = ["Content-Type": "application/json"];
$body = ($data is null) ? null : @Var.toJSON($data);
try {
$response = @HTTP.requestBody($url, $method, $body, $headers);
return @Var.fromJSON($response);
} catch ($e) {
return [error: $e.getMessage()];
}
}
Data validation pipeline
ZYMBA
function $validateEmail($email) {
$email = @String.trim($email);
if (@String.isEmpty($email)) {
return "Email is required";
}
if (!@Regex.test($email, "/^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$/")) {
return "Invalid email format";
}
return null;
}
Date range calculation
ZYMBA
$startOfMonth = @Date.create(1, @Date.getMonth(), @Date.getYear());
$endOfMonth = @Date.create(
@Date.getDaysInMonth(),
@Date.getMonth(),
@Date.getYear(),
23, 59, 59
);
$formattedRange = @Date.format("Y-m-d", $startOfMonth)
. " to "
. @Date.format("Y-m-d", $endOfMonth);
See also
- Strings —
@String,@Regex - Math and Numbers —
@Math,@Number,@Statistic - Dates —
@Date - Encoding and Data —
@Var,@URI,@MIME,@ZLIB,@XML - IO and HTTP —
@IO,@HTTP,@DNS,@Path,@System,@Console,@Output - Security —
@Crypt,@Exception