Quick Start
This page walks you through setting up your environment and writing your first Zymba programs. By the end you will be comfortable with the basic development workflow.
Prerequisites
- ZeyOS SDK installed and available as
zeysdk - A ZeyOS instance to link against
Setting up
Create an application
Bash
zeysdk create myapp
cd myapp
Link to a ZeyOS instance
Bash
zeysdk link --token YOUR_TOKEN --url https://cloud.zeyos.com/instance instance-name
Run your first script
Test that everything works:
Bash
zeysdk run --zymba 'echo "Hello, Zymba!";'
Expected output:
Text
Output
Hello, Zymba!
Language basics in 5 minutes
Variables and types
ZYMBA
$name = "Alice"; // String
$age = 30; // Integer
$price = 19.99; // Float
$active = true; // Boolean
$nothing = null; // Null
$items = [1, 2, 3]; // Array
$config = [host: "localhost", port: 3306]; // Associative array
echo "$name is $age years old";
String concatenation
Use . (dot) for concatenation — NOT +:
ZYMBA
$greeting = "Hello, " . $name . "!";
echo $greeting; // "Hello, Alice!"
// Or use string interpolation in double quotes:
echo "Hello, $name!"; // Same result
warning
+ always performs numeric addition. "Hello" + " World" evaluates to 0, not "Hello World".
Control flow
ZYMBA
// if / else
if ($age >= 18) {
echo "Adult";
} else {
echo "Minor";
}
// unless (inverse of if)
unless ($active) {
echo "Inactive";
}
// for loop
for ($i = 0; $i < 5; $i++) {
echo "$i ";
}
// for-as (iterate array)
$colors = ["red", "green", "blue"];
for ($colors as $color) {
echo "$color ";
}
// while loop
$count = 0;
while ($count < 3) {
echo "$count ";
$count++;
}
Functions
ZYMBA
// Named function
function $add($a, $b) {
return $a + $b;
}
echo $add(3, 4); // 7
// Anonymous function
$double = function($x) { return $x * 2; };
echo $double(5); // 10
// Default parameters
function $greet($name = "World") {
echo "Hello, $name!";
}
$greet(); // "Hello, World!"
$greet("Bob"); // "Hello, Bob!"
Error handling
ZYMBA
try {
$data = @Var.fromJSON($input);
} catch ($e) {
echo "Error: " . $e.getMessage();
}
Working with the standard library
@Array — array operations
ZYMBA
$numbers = [5, 2, 8, 1, 9];
$sorted = @Array.sortAscByValues($numbers);
$big = @Array.filter($numbers, function($n) { return $n > 4; });
$doubled = @Array.map($numbers, function($n) { return $n * 2; });
echo @Array.joinValues($sorted, ", "); // "1, 2, 5, 8, 9"
@String — string operations
ZYMBA
$input = " Hello, World! ";
echo @String.trim($input); // "Hello, World!"
echo @String.toUpper($input); // " HELLO, WORLD! "
echo @String.contains($input, "World"); // true
echo @String.replace($input, "World", "Zymba");
@Date — date and time
ZYMBA
echo @Date.format("Y-m-d"); // "2026-02-08"
echo @Date.format("H:i:s"); // "14:30:00"
$timestamp = @Date.now();
$tomorrow = $timestamp + 86400;
echo @Date.format("Y-m-d", $tomorrow);
@Var — JSON
ZYMBA
// Encode
$data = [name: "Alice", items: [1, 2, 3]];
$json = @Var.toJSON($data);
// Decode
$parsed = @Var.fromJSON('{"name":"Bob","age":25}');
echo $parsed.name; // "Bob"
A real-world example
A complete service that processes an API request:
ZYMBA
include 'zymba:sql,var,http';
// Get request data
$input = @HTTP.getRequestBody();
$data = @Var.fromJSON($input);
// Validate
unless ($data is object) {
@HTTP.setStatusCode(400);
echo @Var.toJSON([error: "Invalid JSON"]);
return;
}
unless (exists $data.name) {
@HTTP.setStatusCode(400);
echo @Var.toJSON([error: "Name is required"]);
return;
}
// Query database
$db = @ZeyOS.selectDatabase();
$sql = @SQL.prepare(
"SELECT ID, name, email FROM contacts WHERE name LIKE ?",
"%" . $data.name . "%"
);
$results = $db.fetchAll($sql, true);
// Respond
@HTTP.setHeader("Content-Type", "application/json");
echo @Var.toJSON([
count: count $results,
results: $results
]);
Running and testing
Execute inline code
Bash
zeysdk run --zymba '$x = 42; echo $x * 2;'
Execute from a file
Define a service in zeyos.app.json, write the code in services/, then zeysdk push and invoke through ZeyOS.
Testing tips
- Start with
zeysdk run --zymbafor quick experiments - Test each function in isolation before combining
- Use
@Console.log()for debug output - Wrap risky operations in
try/catch
See also
- Language Basics — complete reference on variables, types, and operators