LaraGram v4 Documentation

website·Indexed 30 days ago

https://laraxgram.github.io

A PHP framework featuring an object-relational mapper (Eloquent), a service container for dependency injection, and specialized tools for Telegram integration. Includes MTProto for chat and media handling, Luna for building single-page frontends and Telegram Mini Apps (TMA), and a comprehensive suite of core utilities for HTTP requests, queuing, task scheduling, and filesystem abstraction.

Tokens
553.9K
Snippets
3.7K
Records
4K
Agent score
68%

What's inside LaraGram

  1. Overview of LaraGram Logging Channels

    v3
    LaraGram logging is based on "channels," where each channel represents a specific method of recording log information. The system uses a rewritten Monolog library to provide various handlers. By default, LaraGram uses the stack channel to aggregate multiple log channels into one.
  2. Overview of LaraGram Context

    v4
    LaraGram's context capabilities allow you to store information that persists throughout requests, jobs, and commands. This information is automatically appended as metadata to all log entries, enabling better traceability across distributed systems. When a job is dispatched to a queue, the current context is captured and automatically hydrated back into the context when the job executes.
  3. Introduction to LaraGram Template engine

    v4
    Template is a templating engine included with LaraGram that compiles templates into plain PHP code and caches them for zero overhead. Templates use the .t8.php file extension and are typically stored in the app/templates directory. They can be returned from listeners or controllers using the global template helper, which accepts the template name and an optional array of data.
    Bot::onText('hi', function () {
        return template('greeting', ['name' => 'Finn']);
    });
  4. Overview of Luna for LaraGram

    v4

    Luna is an official adapter for LaraGram that allows developers to build modern, single-page style frontends using React, Vue, or Svelte. It eliminates the need for a separate API or client-side routing configuration by keeping application logic (routing, controllers, middleware, validation, and authorization) on the server.

    Luna consists of two parts:

    1. A server-side PHP package (laraxgram/luna) that handles responses.
    2. A client-side JS runtime (@laraxgram/luna) and framework-specific adapters (@laraxgram/react, @laraxgram/vue3, or @laraxgram/svelte).

    It is primarily used for two scenarios:

    • Building SPAs: A drop-in replacement for hand-rolled APIs and client routers.
    • Building Telegram Mini Apps (TMA): Provides cryptographic init-data validation, a telegram auth guard, reactive theme/viewport stores, and wrappers for the Telegram WebApp SDK.
  5. Overview of Eloquent Collections

    v3
    Eloquent methods that return multiple model results (such as the get method or relationship accessors) return instances of LaraGram\Database\Eloquent\Collection. This class extends the base LaraGram collection, inheriting its fluent map/reduce operations and iterator capabilities, allowing collections to be looped over like standard PHP arrays.
    use App\Models\User;
    
    $users = User::where('active', 1)->get();
    
    foreach ($users as $user) {
        echo $user->name;
    }
  6. Overview of the LaraGram Listening System

    LaraGram provides a listening system modeled after Laravel's routing to manage incoming updates. The system is designed to handle input processing, rate limiting, and validation within a structured framework.
  7. Introduction to Blade Templates

    v4
    Blade is a templating engine included with LaraGram that compiles into plain PHP code and is cached until modified, resulting in zero overhead. Blade templates use the .blade.php extension and are typically stored in the resources/views directory. They can be returned from routes or controllers using the global view helper.
    Route::get('/', function () {
        return view('greeting', ['name' => 'Finn']);
    });
  8. Overview of LaraGram Prompts

    LaraGram Prompts is a PHP package designed to add browser-like interactive forms to command-line applications. It supports placeholder text, default values, hints, and validation. It is compatible with macOS, Linux, and Windows (via WSL) and can be used within LaraGram Commander console commands or any standalone PHP CLI project.
  9. Overview of Luna Telegram Feature Helpers

    Luna provides a set of promise-based, SSR-safe helpers exported from @laraxgram/luna with a telegram* prefix. These helpers wrap the native Telegram WebApp SDK, allowing developers to await platform features without manually checking for window.Telegram. They are safe to call outside of Telegram: fire-and-forget helpers will no-op, and promise-based helpers will resolve to a sensible empty value. Rejections should be handled with .catch() for cases like denied permissions or unsupported platforms.
  10. Overview of LaraGram Queues

    LaraGram queues allow you to move time-intensive tasks (e.g., parsing CSV files) to a background process to improve application responsiveness. Configuration is managed in config/queue.php. Supported drivers include database, redis, sync (immediate execution for local development), and null (discards jobs).
  11. Overview of available LaraGram starter kits

    v4

    LaraGram offers three primary starter kits, all powered by Luna, which enables single-page applications (SPAs) and Telegram Mini Apps using server-side routing and Vite compilation.

    • React: Uses React 19, TypeScript, Tailwind, and shadcn/ui.
    • Svelte: Uses Svelte 5, TypeScript, Tailwind, and shadcn-svelte.
    • Vue: Uses Vue Composition API, TypeScript, Tailwind, and shadcn-vue.
  12. Overview of Tempora

    v4
    Tempora is a customized and rewritten version of Carbon that is fully compatible with LaraGram. For detailed technical specifications and usage, refer to the official Carbon documentation.
    # Source repository
    https://github.com/laraXgram/Tempora