API Reference

A concise tour of the core classes, methods, and namespaces that power everyday ZeroPing development. Browse the building blocks below, then jump into the code examples to see them working together in real applications.

ZeroPing organizes code under the App\Core root namespace, with framework utilities nested by responsibility. Import any of these to extend the framework or build your own packages.

App\Core\Routing

Router, Route, and request dispatching.

App\Core\Http

Request, Response, middleware, and sessions.

App\Core\Database

ORM models, migrations, and the query builder.

App\Core\Auth

Authentication, guards, and password hashing.

App\Core\Validation

Validator, rules, and form requests.

App\Core\Console

CLI commands and the Zero command surface.

App\Core\Queue

Job dispatching and worker consumers.

App\Core\Mail

Mailables and transport drivers.

App\Core\Cache

Cache stores, rate limiting, and views.

The most frequently used classes and their key methods. Each signature is shown exactly as you would call it in your application.

Router in App\Core\Routing 5 methods

Registers and resolves application routes, including method verbs, named routes, prefixes, and middleware groups.

Router::get(string $uri, $handler) Register a GET route.
Router::post(string $uri, $handler) Register a POST route.
Router::prefix(string $prefix, Closure $group) Group routes under a URI prefix.
Router::middleware($mw, Closure $group) Apply middleware to a route group.
route(string $name, array $params = []) Generate a URL for a named route.
Model (ORM base) in App\Core\Database 5 methods

Active-record base class for database entities, with fluent queries, relationships, and soft deletes.

Model::create(array $attributes) Insert and return a new record.
Model::find(mixed $id) Find a record by primary key.
Model::where(string $col, $op, $val) Start a fluent query builder.
Model::paginate(int $perPage) Return a paginated result set.
$model->save() Persist changes to the database.
AuthManager in App\Core\Auth 4 methods

Stateless and session-based authentication helpers for logging users in and out.

AuthManager::check() Determine if a user is authenticated.
AuthManager::user() Retrieve the authenticated user.
AuthManager::login(Model $user) Log a user into the session.
AuthManager::logout() Clear the authenticated session.
Validator in App\Core\Validation 3 methods

Validates input against rule strings or arrays, then returns only the safe data.

Validator::make(array $data, array $rules) Create a validator instance.
$v->fails() Return true if validation failed.
$v->validated() Get the validated data only.
Cache in App\Core\Cache 3 methods

Key-value caching with multiple stores, TTL support, and remember helpers.

Cache::get(string $key, $default) Retrieve a cached value.
Cache::put(string $key, $value, $ttl) Store a value with TTL.
Cache::remember(string $key, $ttl, Closure $cb) Get or compute-and-store a value.

Copy-ready snippets for the most common API surfaces, grouped by the task you are solving.

Routing

Map URLs to controllers and generate URLs for named routes.

Register Routes

PHP Register Routes
Router::get('/', [Controller::class, 'method']);
Router::post('/login', [Controller::class, 'method']);
Router::prefix('/admin', fn() => {
    Router::get('/dashboard', ...);
});

Named Routes

PHP Named Routes
Router::get('/posts/{id}', [PostController::class, 'show'])
    ->name('posts.show');

// Generate URL
route('posts.show', ['id' => 1]);

Validation

Validate user input and retrieve only the safe fields.

Validate Input

PHP Validate Input
$validator = Validator::make($data, [
    'email' => 'required|email',
    'password' => 'required|min:8',
]);

if ($validator->fails()) {
    // handle errors
}

Database & ORM

Persist and query records with the active-record model.

Create a Model

PHP Create a Model
$user = User::create([
    'first_name' => 'Rin',
    'last_name' => 'Nairith',
    'email' => 'nairithrin143@gmail.com',
    'password' => PasswordHasher::make('secret123'),
]);

Query Records

PHP Query Records
$users = User::where('role', 'admin')
    ->orderBy('created_at', 'desc')
    ->paginate(15);

$user = User::find($id);

Security

Authenticate users and protect forms from CSRF forgery.

Authentication

PHP Authentication
if (AuthManager::check()) {
    $user = AuthManager::user();
}

AuthManager::login($user);
AuthManager::logout();

CSRF Protection

PHP CSRF Protection
// In view
<?= csrf_field() ?>

// Validate
if (!SessionGuard::validateCsrf($token)) {
    // reject
}

CLI Commands

Common Zero CLI commands for day-to-day development.

Built-in Commands

PHP Built-in Commands
php zero serve           # Start dev server
php zero migrate         # Run migrations
php zero make:controller # Create controller
php zero route:list      # List all routes
php zero cache:clear     # Clear cache