Skip to main content

IO, HTTP, and System

@IO — file operations (61 methods)

Reading files

ZYMBA
$content = @IO.read("/path/to/file.txt"); // Read entire file
$content = @IO.read("/path/to/file.txt", 1024); // Read first 1024 bytes
$lines = @IO.readLines("/path/to/file.txt"); // Read as array of lines
$lines = @IO.readNonEmptyLines("/path/to/file.txt"); // Skip empty lines
$data = @IO.readJSON("/path/to/data.json"); // Parse JSON file
$rows = @IO.readCSV("/path/to/data.csv", ","); // Parse CSV file

Writing files

ZYMBA
@IO.write("/path/to/file.txt", "Hello World");
@IO.append("/path/to/file.txt", "More text");
@IO.appendLine("/path/to/file.txt", "New line");
@IO.writeJSON("/path/to/data.json", $data);
@IO.writeCSV("/path/to/data.csv", $rows, ",");
@IO.echo("/path/to/file.txt"); // Output file contents directly

Atomic read-modify-write

ZYMBA
@IO.readModifyWrite("/path/to/counter.txt", function($content) {
$count = (int) $content;
return (string) ($count + 1);
});

File information

ZYMBA
echo @IO.exists("/path/to/file.txt"); // true/false
echo @IO.isFile("/path/to/file.txt"); // true
echo @IO.isDirectory("/path/to/dir"); // true
echo @IO.getSize("/path/to/file.txt"); // Size in bytes
echo @IO.canRead("/path/to/file.txt"); // true/false
echo @IO.canWrite("/path/to/file.txt"); // true/false

Directory operations

ZYMBA
@IO.createDirectory("/path/to/newdir");
@IO.createDirectories("/path/to/deep/nested/dir"); // Recursive

$files = @IO.listFiles("/path/to/dir");
$dirs = @IO.listDirectories("/path/to/dir");
echo @IO.countFiles("/path/to/dir");

File management

ZYMBA
@IO.createFile("/path/to/file.txt");
@IO.copy("/source/file.txt", "/dest/file.txt");
@IO.move("/old/path.txt", "/new/path.txt");
@IO.delete("/path/to/file.txt");
@IO.deleteIfExists("/path/to/file.txt"); // No error if missing
$tmp = @IO.createTempFile("prefix");

Process execution

ZYMBA
$output = @IO.execute("ls -la");
@IO.executeFlushed("long-running-command"); // Stream output

$safe = @IO.quoteCommandArgument($userInput); // Safe shell quoting

Constants

ConstantDescription
@IO.EOLPlatform line ending (\n on Unix)

@HTTP — HTTP client and server (42 methods)

Making HTTP requests

ZYMBA
// Simple GET — returns body only
$body = @HTTP.requestBody("https://api.example.com/data", "GET");

// POST with JSON body
$json = @Var.toJSON([name: "Alice"]);
$headers = ["Content-Type": "application/json"];
$body = @HTTP.requestBody("https://api.example.com/users", "POST", $json, $headers);

// Full response (includes headers, status code, body)
$response = @HTTP.request("https://api.example.com/data", "GET");

// With timeout and SSL validation
$body = @HTTP.requestBody($url, "GET", null, $headers, 30, true);

Incoming request information (in services)

ZYMBA
$method = @HTTP.getRequestMethod(); // "GET", "POST", etc.
$body = @HTTP.getRequestBody(); // Raw request body
$url = @HTTP.getRequestURL(); // Full request URL

// Query parameters
$param = @HTTP.getRequestQueryVariable("page");
$allQuery = @HTTP.listRequestQueryVariables();

// Form data
$field = @HTTP.getRequestFormVariable("email");
$allForm = @HTTP.listRequestFormVariables();

// Headers
$auth = @HTTP.getRequestHeader("Authorization");
$allHeaders = @HTTP.listRequestHeaders();

// Cookies
$session = @HTTP.getRequestCookie("session");
$allCookies = @HTTP.listRequestCookies();

// File uploads
$file = @HTTP.getRequestFileUpload("avatar");
$allFiles = @HTTP.listRequestFileUploads();

Setting response headers and status

ZYMBA
@HTTP.setStatusCode(200);
@HTTP.setHeader("Content-Type", "application/json");
@HTTP.setHeaders([
"X-Custom": "value",
"X-Request-Id": $id
]);

// Cookies
@HTTP.setCookie("session", $token, @Date.now() + 3600, "/", "", true, true);

// Caching
@HTTP.setCacheExpires(3600);

// Basic auth challenge
@HTTP.setBasicAuthentication("My Realm");

Connection information

ZYMBA
$remoteAddr = @HTTP.getRemoteAddress(); // Client IP
$localHost = @HTTP.getLocalHost(); // Server hostname
$isSecure = @HTTP.isConnectionSecure(); // HTTPS?

@DNS — DNS resolution (7 methods)

ZYMBA
echo @DNS.isValidDomain("example.com"); // true
echo @DNS.isValidIP("192.168.1.1"); // true
echo @DNS.exists("example.com"); // true (has DNS records)

$ip = @DNS.lookup("example.com"); // Resolve to IP
$records = @DNS.resolve("example.com"); // Full DNS records
$host = @DNS.reverse("93.184.216.34"); // Reverse lookup

@Path — file path manipulation (15 methods)

ZYMBA
echo @Path.getExtension("document.pdf"); // "pdf"
echo @Path.getBase("document.pdf"); // "document.pdf"
echo @Path.getFile("document.pdf"); // "document" (without extension)
echo @Path.getDirectory("/foo/bar/baz.txt"); // "/foo/bar"
echo @Path.normalize("/foo/../bar/./baz"); // "/bar/baz"
echo @Path.isAbsolute("/usr/local"); // true
echo @Path.toAbsolutePath("relative/path"); // Full absolute path
echo @Path.getTempDirectory(); // System temp directory
echo @Path.getWorkingDirectory(); // Current working directory

Constants:

"| Constant | Description |" |----------|-------------| | @Path.SEPARATOR | Path separator (/ on Unix) | | @Path.DELIMITER | Path list delimiter (: on Unix) | | @Path.EXTENSION_SEPARATOR | Extension separator (.) |


@System — system information (8 methods)

ZYMBA
echo @System.getHost(); // "cloud.zeyos.com"
echo @System.getMachine(); // Machine identifier
echo @System.getProcessID(); // Current process ID
echo @System.getCurrentMemoryUsage(); // Bytes currently used
echo @System.getPeakMemoryUsage(); // Peak bytes used
echo @System.getMonotonicTime(); // Monotonic clock (for benchmarks)

@System.sleep(1000); // Sleep for 1000 milliseconds

Constants:

"| Constant | Description |" |----------|-------------| | @System.PLATFORM | Platform identifier | | @System.VERSION | Runtime version | | @System.VERSION_ID | Numeric version ID |


@Console — logging (7 methods)

ZYMBA
@Console.log("Debug message");
@Console.log("Multiple", "values", 42);

$count = @Console.countMessages();
$messages = @Console.listMessages();
$summary = @Console.getSummary();

@Output — output buffering (6 methods)

ZYMBA
echo @Output.getLevel(); // Current buffer nesting level
echo @Output.getSize(); // Current output buffer size

$content = @Output.getContent(); // Get buffered content
@Output.echo($content); // Write to output
@Output.flush(); // Flush buffer
@Output.clear(); // Discard buffer