Skip to main content

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

ClassMethodsPurpose
@String96String manipulation — trim, replace, split, case, search
@Regex11Regular expression testing, matching, and replacing
@Math62Mathematical functions — trig, log, rounding, random
@Number42Number formatting, type checks, base conversion, rounding
@Statistic29Statistical analysis — mean, median, mode, variance
@Date31Date/time — now, format, parse, components, timezone
@Var30JSON/PHP serialization, type inspection, cloning
@URI20URL encoding/decoding, query strings, parsing
@MIME12Base64 and MIME encoding
@ZLIB6Compression: deflate, inflate, gzip
@XML5XML parsing and generation
@IO61File, directory, and stream operations
@HTTP42HTTP client/server — requests, headers, cookies
@DNS7DNS resolution and validation
@Path15File path manipulation
@System8System info: host, PID, memory usage
@Console7Logging and debug output
@Output6Output buffering control
@Crypt22Hashing, encryption, JWT, UUID generation
@ExceptionException creation and stack traces
@Function7Function introspection and reflection
@Array97Array manipulation (covered in Arrays and Collections)
@SQL4SQL query preparation (covered in Platform Integration)
@ZeyOS16Platform 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 ([email protected]($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